3 ms·
There's lots of instances like if (something....) return !0; else return !1; is there any reason why they aren't simply using `true` a
by pooriaazimi 14y ago
There's lots of instances like
if (something....)
return !0;
else
return !1;
is there any reason why they aren't simply using `true` and `false`?
(because !1 is defined to return literally `false` and !0 to return `true`)
- esrauch 14y agoLikely was "true" in the original source (and the source in separate files) and was replaced by some minifier. Not clear if these are the files verbatim or if it was automatically formatted from minified js.
- jschorr 14y agoIt is one of the peephole optimizations that Closure Compiler performs to save some space (read: 2-3 characters) in the final output: http://code.google.com/p/closure-compiler/source/browse/src/com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntax.java http://code.google.com/p/closure-compiler/source/browse/src/.... The compiler actually has a lot of cool little tricks like that to save space (since saving even a few bytes for a property like, say, Gmail, can translate to very large numbers very quickly)