!! 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.

%MINIFYHTML4f6a243127a7850123d02df1ff4db62223%name = isName === 'Brian' ? true : falseCode 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 = !!userLoggedInCode language: JavaScript (javascript)

Above, the double bang will return false.

About Author /

Leave a Comment

Your email address will not be published.

Start typing and press Enter to search