How to convert Boolean by js
This article is about how js converts Boolean types. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Transform Boolean type
Regular Boolean values are only true and false, but in JavaScript we can think of other values as' truthy''or 'falsy'.
Except for 0, "", null, undefined, NaN and false, we can think of everything else as' truthy''.
We can use the negative operator! Converts a series of variables to "boolean".
Const isTrue =! 0th Const isFalse =! 1x Const alsoFalse =!! 0x console.log (isTrue); / / Result: trueconsole.log (typeof true); / / Result: "boolean" Thank you for reading! This is the end of the article on "how to convert js into Boolean". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!