Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Bucharest, ROMANIA
    Thanked 379 Times in 375 Posts

    Question just some thoughts about new Date() object

    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
    Offshore programming

  2. #2
    Regular Coder martin_narg's Avatar
    Join Date
    Jul 2002
    Chamonix, France
    Thanked 3 Times in 3 Posts
    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:
    (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

    Last edited by martin_narg; 10-13-2005 at 02:29 PM.
    "Cos it's strange isn't it. You stand in the middle of a library and go 'Aaaaaaaaaaaaaaaaggggggghhhhhhh!'
    and everybody just stares at you. But you do the same in an aeroplane, and everybody joins in."
    -Tommy Cooper


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts