
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is a constructor to create String object in JavaScript?
To create a String object in JavaScript, use string.constructor. A constructor returns a reference to the string function that created the instance's prototype.
Example
You can try to run the following code to create a String object with the constructor −
<html> <head> <title>JavaScript String constructor Method</title> </head> <body> <script> var str = new String( "This is string" ); document.write("str.constructor is:" + str.constructor); </script> </body> </html>
- Related Questions & Answers
- How to create JavaScript objects using object() constructor?
- What is a constructor method in JavaScript?
- What is a default constructor in JavaScript?
- Add a property to a JavaScript object constructor?
- Add a method to a JavaScript object constructor?
- What is function() constructor in JavaScript?
- What is the difference between new operator and object() constructor in JavaScript?
- What is a constructor in Java?
- How to create JavaScript Date object from date string?
- What is a Global Object in JavaScript?
- How to create a String object in C#?
- What are the rules to create a constructor in java?
- What is a copy constructor in C#?
- What is a static constructor in C#?
- How to create a multidimensional JavaScript object?
Advertisements