+
Addition-
Subtraction*
Multiplication/
Division%
Remainder (Modulus)**
Exponent100 + 4 * 11
Infinity
-Infinity
NaN
- not a number"Mary's car is red."
'The monkey says "goodbye"'
`Back ticks are called "template literals"`
"This is the first line\nAnd this is the second"
will result in:
This is the first line
And this is the second
"A newline character is written like \"\\n\"."
will result in:
A newline character is written like "\n".
+
Concatenation - Join two strings together"Patch my boat " + "with chewing gum"
will result in:
"Patch my boat with chewing gum"
`Strings can
now span
lines`
${}
will be evaluated, converted to a string, and included at that positionlet number = 100;
console.log(`half of ${number} is ${number / 2}`);
displays:
half of 100 is 50
typeof
- produces a string naming the type-
negate (number)+
plus (number)!
not (bolean)true
or false
>
and <
result in boolean values5 > 2 // true
"abc" > "def" // false
>=
Greater than or equal<=
Less than or equal==
Equal!=
Not EqualThese work with boolean values
&&
AND||
OR!
NOTtrue ? 1 : 2 // 1
false ? 1 : 2 // 2
null
undefined
undefined
null
has a slightly different meaning that we will see later"one" + 2 // "one2"
"5" * 2 // 10
0
, ""
, undefined
, null
, NaN
are false
true
===
precisely equal (value and type)!==
precisely not equal==
and !=
"2" == 2 // true
"2" === 2 // false
&&
and ||
true || console.log("Hello")
true && console.log("Hello")