Reputation: 5911
I am going through a javascript library and I would like to know why you would define a variable like this...
points: {
show: !0
},
Why would you do show: !0
instead of just show: 1
?
I don't think this question is necessarily specific to javascript but I tagged the question with it anyway just in case it was actually something language specific.
Upvotes: 1
Views: 60
Reputation: 887449
In Javascript, !
with any falsy value returns true
.
This is a common trick used by minifiers to save two character.s
Upvotes: 6
Reputation: 4278
That evaluates to true. Not quite sure why it's being used as there's no context so that's all I can tell you.
Upvotes: 1