Home > Article > Web Front-end > What does !! in js mean?
The !! operator in JS: used to convert a value to a Boolean value. Operation: Perform logical NOT operation on the value. Then perform a logical NOT operation on the result. Result: true: when the value is not false, not the empty string, not null, not undefined. False: When the value is true, empty string, null, undefined. Purpose: Convert any value to a Boolean value. Forces an explicit conversion to a boolean value. Eliminate uncertain values.
!! in JS
In JavaScript, the "!!" operator is a logical negation ( NOT) operator, used to convert a value to a Boolean value. Its function is double negation, that is, after performing a logical NOT operation on the value, perform a logical NOT operation again.
How to use
Syntax:
<code>!!<value></code>
where
Operation result
The purpose of double negation
Double negation operator!! Mainly used for the following purposes:
Code Example
<code>console.log(!!true); // true console.log(!!false); // false console.log(!!0); // false console.log(!!1); // true console.log(!!''); // false console.log(!!'abc'); // true</code>
The above is the detailed content of What does !! in js mean?. For more information, please follow other related articles on the PHP Chinese website!