View Full Version : just some thoughts about new Date() object

10-13-2005, 10:26 AM
maybe it is a stupid question, but if
var today = new Date() is an object, why it does not accept arguments property?

I know that Date() is a predefined object, yet it looks rather weird that

var today = Date() returns directly a string, while
var today = new Date() is an object needs toString()/valueOf() methods to return a string/number

10-13-2005, 02:24 PM
Hey mate - I had a think about this and here's my musings:
the Date constructor is a function, and functions accept arguments. The reference to this function property (arguments) would be:
Date.constructor.arguments (this returns null and not unidentified as would be the case if the property did not exist.
I would imagine that the arguments are stored in the hash table for the function (in this case the Date function). But as they are not needed to be permanently stored, the garbage collector will pick up this property and clean it out in the same way as declaring a local variable in a function gets memory allocated and garbage collected after each instance usage.

I'll bet all the herring in sweden that jkd knows a shorter answer than this tho ;)