JS Daily #25 - Double Negating a Value
What is the output of following code?
const str = "Backbencher"; console.log(!!str);
The output is
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.