Jump to content

return<<<


Drycodez
 Share

Recommended Posts

The constructor for a String doesn't return a value; the value of the variable str is a reference to the String instance itself. This is the same as creating a copy of any other prototype:

var a = new MyObject(); // a now contains reference to new MyObject instance

Link to comment
Share on other sites

If I understand what you're asking, the built-in JavaScript objects are different from objects you can currently make on your own. Here's what you can do with a string object:var s = "Hi";alert(s); // "Hi"Let's call "Hi" the literal value of s. Maybe there's a real name. I don't know. I think what you are asking is if you can create your own object constructor that returns a literal value the same way a string object does. The answer is no. Maybe in the future. That might be part of the getter/setter suite. I'm not sure.What you CAN do is add properties and methods to the prototype of a string object so that it behaves like a custom object.EDIT:Also, as mentioned many times elsewhere, there is no difference between using a String constructor and simply assigning a literal string to a variable. The objects that are created are exactly the same.

Edited by Deirdre's Dad
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...