N
Nik
As title and what is the difference?
THANKS!!!!!!!!!
THANKS!!!!!!!!!
As title and what is the difference?
THANKS!!!!!!!!!
i don't think there has difference,maybe +new Date() is a expression,
new Date() is a object
Nik said:As title and what is the difference?
Lasse said:Please repeat the question in the body of the message. It breaks
readability to have to refer to the subject while reading the message.
new Date() creates a Date object.
The unary + (positive sign) operation converts its operand to a
primitive numeric value. For a Date object that is equivalent to
calling valueOf (which is againg equivalent to calling getTime)
on the object.
I.e., one is a number, the other is an object.
/L
Johannes said:Stevo :
Yes, you could even omit the zero.
Whether it is an optimisation is debatable. A gain of speed is unlikely.
It does save typing, but as your question and the OP's show, at some
expense of clarity.
Stevo said:Yes it reduces clarity and is unlikely to give a speed gain. I'm
thinking only in terms of file size. If I've got 20 of them then
there's 200 bytes saved. If I can manage 5 similar sized optimizations
on a 20K file I'm getting a nice file size reduction out of it.
Lasse said:If you have 20 of anything, you should introduce a new function intead,
and call that 20 times. If the function name is shorter than "+new Date",
it might even save space.
/L
Johannes Baagoe said:Lasse Reichstein Nielsen :
It seems to be so, but I haven't found the normative reference.
In the two implementations I have checked (SpiderMonkey and V8),
if you override Date.prototype.getTime, the automatic conversion
to a numeric value remains unchanged. Not so if you override valueOf.
Johannes said:Stevo :
Johannes Baagoe :
Oops, sorry. No, you *must* omit the zero. Otherwise, start will be
something like "0Fri Sep 11 2009 20:20:25 GMT+0200 (CEST)".
Johannes said:Thomas 'PointedEars' Lahn :Learn to quote.
To take the canonical example (e.g.,
http://www.anta.net/misc/nnq/nquote.shtml#Q6) :
In which style is it easier to attribute what to whom [...]
Lasse Reichstein Nielsen :
It seems to be so, but I haven't found the normative reference.
In the two implementations I have checked (SpiderMonkey and V8),
if you override Date.prototype.getTime, the automatic conversion
to a numeric value remains unchanged. Not so if you override valueOf.
Yes, you could even omit the zero.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.