Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Land some additional tweaks related to running through JSLint.
- Loading branch information
Showing
5 changed files
with
10 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a4043cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In reference to 806, what's wrong with
+new Date()
?a4043cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@james: Nothing in particular (in that it works) but I've balked against it in the past because it's particularly "magical" and not always obvious what it's doing to someone who may be reading the source - whereas (new Date()).getTime() is very explicit and very obvious as to what the result is.
a4043cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point. I'm surprised closure compiler doesn't switch
new Date().getTime()
for+new Date
...a4043cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing magical about it. ECMA 5th Ed.
Page 169, Section 15.9.3.1 [[PrimitiveValue]]
makes it pretty clear.(new Date).valueOf();
would also do :Pa4043cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jdalton: To someone that reads specifications for fun, of course there's "Nothing magical about it." - but it's undeniable that it's much more obtuse than just doing a straight
(new Date()).getTime();
or(new Date()).valueOf();
.a4043cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hehe, I hear @kangax is getting a tramp stamp that reads
"strict";
a4043cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*erm
"use strict";
, humor fail :Da4043cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use +new Date() and then include a comment. You know, one of those new-fangled thingamawhatsits often included in source code just like this that explains to the uneducated developer what that particular bit of magic does?
a4043cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments are verboten.
On a serious note, it's a popular idea that code should be clear - that if a piece of code needs comments to explain what it does, then that piece of code should be rewritten no longer to need comments.
Appropriate optimizations are exceptions to this rule, as are such things as high-level descriptions of algorithms and data structures, high-level descriptions of design and architecture, examples of how to invoke the code, key assumptions and contexts, etc.