On the subject of minification, I see a lot of lines that look like this[1]:
fireToken : 1 === f.tradeTokens.data.fireToken ? !0 : !1,
Why might that be a desired output from a minifier? Why not simply fireToken : 1 === f.tradeTokens.data.fireToken,
[1] https://gist.github.com/anonymous/5133829#file-simcityui-js-...The original code could have been written as "condition ? true : false" and it's just not a pattern the minifier picks up on.
Probably a terrible mistake from the developer, not the minifier.
fireToken: f.tradeTokens.data.fireToken === 1 ? true : false
In my company I see JS code like the following: if (!!someFlag) { /* ... */ }
Here's another example. Starting at line 91, you get the following:
The above code uses commas in a particular way that usually means it comes from a minifier. JavaScript has a comma operator, which is basically just a statement separator, but it has the interesting property that it joins two statements as a single expression. As in many C-style languages, control flow operators like if and while don't require curly braces, and apply to the immediately following statement if they are absent. The combination of these two means that is equivalent to which is shorter by a single character. Because the line of code joined by commas is now an expression, this also lets us abuse the short-circuit property of boolean operators, re-writing the above like so: for a further savings of one more character.You pretty much never see the comma operator in code written by humans, because it's not useful for anything. Seeing them in production code, especially the way shown above, almost always means the code came out of a minifier. That actually broke the Opera browser a few months back--apparently the parser ran out of stack space when handling a single expression consisting of over 1,400 comma-separated statements.