1 !== true and 0 !== false , but !0 === true and !1 === false . The compiler simply ensures that the type remains logical.
Consider the following example:
var a = true; if( a === true ) { console.log( 'True!' ); } if( a === 1 ) { console.log( 'You should never see this.' ); }
If you change the first line to var a = 1; , the first condition will be false, and the second will be true. Using var a = !0; , the script will work correctly.
Jjj
source share