JS Daily 25 - Double Negating a Value

Last updated on 15 Dec, 2020

What is the output of following code?

const str = "Backbencher";

The output is true.

This is the easiest way to convert any value to its equivalent boolean value. First negation(!) converts the value to boolean, but it will be inversed. We then use one more negation to invert the value again.

--- ○ ---
Joby Joseph
Web Architect