I was looking at some code in createjs and I noticed a variable being assigned as a = !0 instead of a = true. What would be the benefit of this syntax being a = !0
Asked
Active
Viewed 49 times
0
-
Can you show us a small snippet (i.e. a [mcve]) so we can have some context? My guess is just that it's shorter (in a minified situation that's desired) – Andrew Li Jul 16 '18 at 15:16
-
2it's 2 characters instead of 4 – apokryfos Jul 16 '18 at 15:16
-
@apokryfos make your code less readable but save 2 bytes.... yey.... I get when minifiers do that. but nobody should write this in code that is checked in – Philipp Sander Jul 16 '18 at 15:19
-
2@PhilippSander usually this is never in checked in code. OP noticed it in a 3rd party library and typically these go through a code optimizer before they are released, which is why you would see it a lot in the libraries you include but usually not in the "source code". – apokryfos Jul 16 '18 at 15:22