All data in computers can be reduced to bits, positive/negative charges expressed as ones and zeros.
Numbers, which can be whole, negative, and decimal values. Their main benefit is using arithmetic operations to calculate new numbers.
The remainder operator returns the leftover value after division.
314 % 100 returns
100 % 10 returns
NaN is returned after any operation that doesn't return a real result.
0 / 0 will return
NaN, as well as
Infinity - Infinity.
Strings are basic text enclosed by matching quotes.
Quotes or other special characters inside a string need to be escaped with a backslash.
"\'It is a dangerous journey,\' the main said."
"This is the first line\nAnd this is the second"
String with backticks can include functions or operations, if they're enclosed in a
Unary Operators are symbols written as words
typeof tells you a value's type, so
typeof 4.5 returns
Boolean values are simply true or false
You can use comparison values that return boolean values, such as
3 > 2 returning
Logical operators such as
|| also return boolean values.
The negative operator flips an integer, so
- 5 returns
The not operator flips the boolean value on it, so
Ternary operators evaluate an expression and can return different values if it's
true ? 1 : 2 returns
1, but if it was false it would return
Empty Values show a lack of meaningful values or info. If a value must be returned but none is produced, you get an empty value.
These can be either
undefined, and they're mostly the same.
Type Coercion is when operators are applied to the wrong value types and quickly convert the value to what is needed, such as converting
"5" from a string to
5 as an integer. To test for any unexpected type conversions or missing values, use the
!== comparison operators.