Operators
General
Info:
- put spaces around operators
Arithmetic
- Operator Precedence
*
and/
have higher precedence than+
and-
.- parentheses are computed first
()
- same precedence is computed from left to right
Assignment
bla
Concatenation
Info:
+
and+=
can be used for adding Stringslet text1 = "What a very ";
text1 += "nice day";
Danger:
Numbers
+
String
will result aString
let y = "5" + 5; // String!
let z = "Hello" + 5; // Hello5let x = 16 + 4 + "Volvo"; //20Volvo
let x = "Volvo" + 16 + 4; // Volvo164
Comparison
bla
String
bla
Logical
bla
Comparison
Bitwise
Ternary
bla
Type
typeof
returns the type of a variable or an expression
typeof "" // Returns "string"
typeof "John" // Returns "string"
typeof "John Doe" // Returns "string"typeof 0 // Returns "number"
typeof 314 // Returns "number"
typeof 3.14 // Returns "number"
typeof (3) // Returns "number"
typeof (3 + 4) // Returns "number"let car; // Value is undefined, type is undefined