JavaScript "cheat sheet"

Data types:
Values Type
""
0
1
"0"
"1"
[] (empty array)
{} (empty object)
null
undefined
NaN
Infinity
console
console.log
document
document.write
true
false
Arithmetic operations:
Operation Result
"2" + "5" =
"2" + 5 =
2 + "5" =
"8" - "4" =
"8" - 4 =
8 - "4" =
"10" * "7" =
"10" * 7 =
10 * "7" =
"9" / "3" =
"9" / 3 =
9 / "3" =
"6" % "5" =
"6" % 5 =
6 % "5" =
Order of operations:
Order of operations Result
10 + 5 % 2 =
(10 + 5) % 2 =
10 + (5 % 2) =
10 * 5 % 2 =
(10 * 5) % 2 =
10 * (5 % 2) =
Conditional (ternary):
Conditional Result
0 == 1 ? "fish" : "duck"
(0 == 1) ? "fish" : "duck"
0 == (1 ? "fish" : "duck")
Truthy/Falsy:
Value Truthy/Falsy
0
1
2
"0"
"1"
"2"
"cow"
""
" "
null
undefined
NaN
Infinity
[] (empty array)
{} (empty object)
{vegetable: "cabbage"}
Logical operators:
Short circuit evaluation Result
"dog" || "cat" || "cow"
"dog" && "cat" && "cow"
"dog" && "cat" || "cow"
"dog" || "cat" && "cow"