Jump to content

return<<<


Drycodez

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.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...