Personally, I find that the expression +new Date is obtuse and doesn't really explain what is happening very well. You're creating an object - then putting a plus next to it - to get some result. Is it a string? a number? Whereas (new Date).getTime() is very explicit: You know that you're getting the time back.
I just landed one fix: In support.js we were using (new Date).getTime() instead of our now() function that we use everywhere (save for Sizzle, which is a separate project). There is no appreciable performance difference between the two techniques - and certainly not in any quantity that would affect us more than the actual now() function call. --John On Thu, Dec 3, 2009 at 6:13 AM, Ash <ash.sea...@gmail.com> wrote: > Grepping for 'new Date' through the jquery source shows a bit of > variety in Date -> Time handling. > > Casual question really: Is there an aim to get consistency in the code- > base, or a "house style" on how to handle dates? > > Some of the variety seems to come from context and purpose: when > you're optimising for code-size "+new Date" is great, but people shy > away from using that in the middle of an expression: > > src/sizzle/sizzle.js: id = "script" + (new Date).getTime(); > > I know the git repo contains source from several different projects, > and suspect the variation in style may reflect the average competence > of project contributors. > > I'm probably over-analysing, but wondered if anyone else had noticed > this, or checked whether "+new Date" performed any differently to "new > Date().getTime()" etc. > > -- > > You received this message because you are subscribed to the Google Groups > "jQuery Development" group. > To post to this group, send email to jquery-...@googlegroups.com. > To unsubscribe from this group, send email to > jquery-dev+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/jquery-dev?hl=en. > > > -- You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-...@googlegroups.com. To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en.