admin管理员组

文章数量:1342902

I found some code using

!0
!1

I guess this is just the same things than

true
false

is there a reason for doing that or is just some abbreviation?

I found some code using

!0
!1

I guess this is just the same things than

true
false

is there a reason for doing that or is just some abbreviation?

Share asked Mar 25, 2013 at 14:39 PaoloPaolo 2,4726 gold badges34 silver badges45 bronze badges 6
  • 5 Find who wrote that code and make a note not to hire him or her for any future work. :-) – Pointy Commented Mar 25, 2013 at 14:40
  • 1 I would guess it's mainly for obfuscation/uglification. – Reinstate Monica -- notmaynard Commented Mar 25, 2013 at 14:42
  • 3 @Pointy This code is produced by JavaScript Closure Compiler, as an example. Is it a time to fire it? ;) – VisioN Commented Mar 25, 2013 at 14:42
  • @VisioN Ha ha! Well then that makes perfect sense I guess. – Pointy Commented Mar 25, 2013 at 14:44
  • In JS it make sense, it can save some loading time. But its definetely ugly :-) – Gatekeeper Commented Mar 25, 2013 at 14:44
 |  Show 1 more ment

1 Answer 1

Reset to default 17

If you really care about bandwidth and loading time then you need code pression. !0 and !1 is a pressed version of true and false.

本文标签: javascriptAny reason to use 0 instead of trueStack Overflow