graduate Posted January 28, 2012 Share Posted January 28, 2012 Does the Date object has a special behavior when it is used in an expression? var obj = {}, date= new Date(); 20 + obj; // obj.valueOf() is called first20 + date; // date.toString() is called first, the result is a string If I try to emulate the Date object I could not do it because in the "x + y" expressions I can't to force my object to invoke toString() method first. Link to comment Share on other sites More sharing options...
Ingolme Posted January 28, 2012 Share Posted January 28, 2012 You shouldn't use just the object itself. Use one of its methods or properties. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.