//Logical Binary and Ternary Operators in Javascript
== Equal to
=== Strictly equal to
!= Not equal to
!== Strictly not equal to
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
&& Logical and
|| Logical or
! Logical not
? Ternary operator
? call ternary operator is shorcut for, "if statement".
// below we make object with key id, and assign it a value from body.id.
// if body.id is null it will return false and it will assign it res.id value.
{ id: body.id? body.id : res.id }
// we can write it in if statement like this
if(body.id){
return {id:body.id}
}else{
return {id:res.id}
}
var x = 5; // assign the value 5 to x
var y = 2; // assign the value 2 to y
var z = x + y; // assign the value 7 to z (5 + 2)
let x = 5; // assign the value 5 to x
let y = 2; // assign the value 2 to y
let z = x + y;