3 ms·
var NULL = null, TRUE = true, FALSE = false I'm not sure I understand this. Why assign these to variables?
by FuzzyDunlop 14y ago
var NULL = null, TRUE = true, FALSE = false
I'm not sure I understand this. Why assign these to variables?
- wendelinsky 14y agoThat is part of the es6-collections polyfill included as part of smap.js. If I understand correctly, it is for safety (for example you cannot override the value of "true").
- Twisol 14y agonull, true, and false are all keywords. Isn't undefined the only one that can be redefined? (And then it's just equal to void 0.)
- emwendelin 14y agoYep, you're right. I forgot about that.
- esrauch 14y agoI think the reason for these is for js minification. With these assignments a simple minifier will replace those three variables with a line like this: var a=null,b=true,c=false; Then your minified js will be smaller because all other instances of true, false and null will be one character. Whether or not this is a reasonable optimization is debatable but in terms of pure code size it would be a win.