Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get opposite boolean value of variable in Javascript

Tags:

javascript

var a = true; 

How to get opposite value of a (false) and vice versa?

like image 482
s.webbandit Avatar asked Oct 07 '12 20:10

s.webbandit


People also ask

How do you get the opposite of a boolean value?

And the "not" ( ! ) operator returns the opposite of the boolean value to its right. That is, true becomes false and false becomes true .

How do you flip a boolean in JavaScript?

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.

Can a function return a Boolean value JavaScript?

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.

Can boolean be undefined JavaScript?

The Boolean value of undefined is false. The value of Not only undefined but also null, false, NaN, empty string is also false.


1 Answers

>>> a = true; true >>> !a; false 
like image 180
richardaday Avatar answered Oct 16 '22 11:10

richardaday