Jump to content

toString() and valueOf() Method


shreyaskudav

Recommended Posts

What are uses of this method?...although we can just get the results by adding the variable in document.write(xxxx)..?And if there's a significant reason after it then, whats the difference between toString() and valueOf()...although their results are the same...?

Link to comment
Share on other sites

What are uses of this method?...although we can just get the results by adding the variable in document.write(xxxx)..?And if there's a significant reason after it then, whats the difference between toString() and valueOf()...although their results are the same...?
You may want to have a look at this if you found thw w3schools tutorial not enough:http://javascript.about.com/od/guidesscrip...x/a/valueof.htm
Link to comment
Share on other sites

The toString() method is usually used by the system itself. When you use alert() or document.write() the browser uses the toString() method internally. So, when you create your own classes, be sure to override the toString method to make it something that properly represents your object.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...