This post is also available in: Japanese
I make a note so that not forgot.
case: one exclamation mark
var a = true; console.log(!a); //false // "booblean" can also converted to a number using "Number". console.log(Number(!a)); //0
If you want a number in return value rather than booblean(true/false), then use Number(1/0).
case: two exclamation mark
“true” into “not not”, then “true” is returned.
var b = true; console.log(!!b); //true
In the following code, if you use the exclamation mark, you will see that it is converted to booblean(true/false).
var c = undefined; // same if var c =0,null console.log(!!c); //false //Object is true var d = Object; console.log(!!d); //true