Falsy Values
null
-
undefined
NaN
0
-
""
empty quotes - false
&& and ||
&&
- Returns the first falsy value
- If none found, it will return the last truthy value
||
- Returns the first truthy value
- If none found, it will return the last falsy value
// both are truthy
truthy1 && truthy2; // truthy2
truthy1 || truthy2; // truthy1
// both are falsy
falsy1 && falsy2; // falsy1
falsy1 || falsy2; // falsy2
// 1st truthy, 2nd falsy
truthy1 && falsy1; // falsy1
truthy1 || falsy1; // truthy1
// 1st falsy, 2nd truthy
falsy1 && truthy1; // falsy1
falsy1 || truthy1; // truthy1
Top comments (0)