!! Double Bangs

There are several ways to determine conditional logic in Javascript. The most common across all languages would be the classic IF/Else/Else If logical statements.

The next common would be ternary expressions. These expressions return a value of true/false and execute logic based on the condition.

name = isName === 'Brian' ? true : false
Code language: JavaScript (javascript)

if isName is ‘Brian’ then name would be true, otherwise it’s set to false.

Another way to check and assign a result is with double bangs.

userLoggedIn = '' isUserLoggedIn = !!userLoggedIn
Code language: JavaScript (javascript)

Above, the double bang will return false.

Leave a Comment