var a = true;
How to get opposite value of a
(false) and vice versa?
And the "not" ( ! ) operator returns the opposite of the boolean value to its right. That is, true becomes false and false becomes true .
To toggle a boolean, use the strict inequality (! ==) operator to compare the boolean to true , e.g. bool !== true . The comparison will return false if the boolean value is equal to true and vice versa, effectively toggling the boolean.
You can return a boolean value from a JavaScript function. Create a function and use the if statement to evaluate the given value to the function. And return true or false according to the conditions.
The Boolean value of undefined is false. The value of Not only undefined but also null, false, NaN, empty string is also false.
>>> a = true; true >>> !a; false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With