What does double exclamation mark mean in JavaScript?

Double exclamation mark in JavaScript is used to turn a non-boolean value to a boolean value.

Everything except "" (empty string), 0, NaN, null, undefined becomes true if you put !! in front of it.

Here's how it works:

const zero = 0;
const helloWorld = 'Hello World!';
const emptyString = "";
const fortyTwo = 42;

console.log(!!zero); // false
console.log(!!helloWorld); // true
console.log(!!emptyString); // false
console.log(!!fortyTwo); // true