Skip to content Skip to sidebar Skip to footer

Javascript If Statement Double Exclamation Mark Operator Redundancy

If I have an if statement that doesn't have a conditional operator, does it matter if I use the double exclamation mark operator - !!? For example... if ([]) { } vs... if (!!([])

Solution 1:

Yes. Both of these will print for any Boolean(x) === true

For more detail, you can find truthy, falsy and Boolean in JavaScript

For esier to understand, you can use Boolean([]) // true

Post a Comment for "Javascript If Statement Double Exclamation Mark Operator Redundancy"