!! Double not operator
How it works:
- The first ! negates the value, converting it to its opposite boolean value. If the original value is truthy, this results in false, and if the original value is falsy, this results in true.
- The second ! negates it again, so you're back to the original truthiness of the value, but now as a boolean true or false instead of the original value.
!!true; // true !!false; // false !!null; // false !!undefined; // false !!0; // false !!1; // true !!'hello'; // true !!''; // false
java-script/double-not-operator.txt · Last modified: 2023/08/10 04:13 by odefta