Get the App
SLTechnology News&Howtos  ›  Development  › 

How to convert Boolean by js

Shulou Source: shulou.com Published: 2022-06-01 04:58:34 10月28日 Update

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!

Tags: Content more article good practical variable only can pass regular article is in see knowledge operator reference help related operation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei vpn Apple Linux Docker