As you all know there is a toString()
method for object which is called whenever the casting is required.
I was wondering if there is such a method for casting to number (like the Date object in which +new Date()
returns the getTime()
method's value).
For example (let's say there is toNumber
method):
function MyObj(){}
MyObj.prototype.toNumber = function(){
return 1362;
}