Is the !! (not not) operator in JavaScript equivalent to reverse process of not operator?


Yes, the not not operator is the reverse process of not operator. If any value is true then single ! (not) will return false and !! will return opposite value (true).

The not operator −

var flag=true;
console.log(!flag);

The not not operator −

var flag=true;
console.log(!!flag);

Example

Following is the code −

var flag=true;
console.log("The result of single !=")
console.log(!flag);
console.log("The result of single !!=")
console.log(!!flag)

To run the above program, you need to use the following command −

node fileName.js.

Here, my file name is demo247.js

Output

This will produce the following output on console −

PS C:\Users\Amit\javascript-code> node demo247.js
The result of single !=
false
The result of single !!=
True

Updated on: 09-Nov-2020

139 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements