Operators
Comparison Operator
// ALL of them return a boolean true|false
> // greater then
< // less than
>= // greater or equal
<= // less or equal
== // Equality
!= // Not Equal
=== // strict equlity (also the data type (number, integer) must be the same)
!== //strict non-equality
Examples for ==
:
false==false //true
7=='7' //true
0==false //true
0=='' //true
null==undefined //true
Examples for ===
:
// Should in most cases go with ===
2==='2' //false
2===2 //true
0===false //false
undefined ===0 //false
null = null //true
Logical Operator
&& //AND
|| //OR
! //NOT
//Precedence of the Operator
// ! has the highest precedense then comes && and then || -> alter it by ()
! //runs first
&& //runs seconds
|| //runs third
Further Info for precedence for other operator you can see in the docs.
Ternary Operator
//condition ? expIfTrue : expIfFalse
num ==== 7 ? consoloe.log('seven'): console.log('Not seven')
// if status is offline color should be red
let color = status === 'offline'?'red':'green'