Dung (Donny) Nguyen

Senior Software Engineer

Convert Value to Boolean Equivalent with !!

The !! operator in JavaScript is a double logical NOT used to convert a value to its boolean equivalent. Itโ€™s a clever shorthand for coercing any value into a true or false.

๐Ÿ” How It Works

โœ… Example

!!"hello"      // true โ€” non-empty string is truthy
!!0            // false โ€” 0 is falsy
!!undefined    // false โ€” undefined is falsy
!![]           // true โ€” an empty array is truthy
!!null         // false โ€” null is falsy

๐Ÿง  Why Use It?

โš ๏ธ Tip

Avoid using !! in places where readability matters for beginners. Itโ€™s concise but can be cryptic if youโ€™re not familiar with coercion.