Jump to content

Date.toString() is invoked first


graduate

Recommended Posts

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

Archived

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

×
×
  • Create New...