shreyaskudav Posted July 13, 2011 Share Posted July 13, 2011 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 More sharing options...
tinfanide Posted July 13, 2011 Share Posted July 13, 2011 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 More sharing options...
Ingolme Posted July 13, 2011 Share Posted July 13, 2011 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 More sharing options...
jeffman Posted July 13, 2011 Share Posted July 13, 2011 I execute those methods for debugging only. When I need to actually USE the elements of an object or array, I do it in a way that fits my app. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.