typeof 42; // "number"
typeof 1.4142135; // "number"
typeof 'hello'; // "string"
typeof 'false'; // "string"
typeof false; // "boolean"
typeof true; // "boolean"
typeof {key: 'value' }; // "object"
typeof function () {}; // "function"
typeof Math.sin; // "function"
typeof null; // "object"
typeof undefined; // "undefined"
++value // increments value by 1 before the statement is evaluated
value++ // increments value by 1 after the statement is evaluated
--value // decremented value by 1 before the statement is evaluated
value-- // decremented value by 1 after the statement is evaluated
!value // negate the boolean value
a && b // returns the logical AND of a and b
a || b // returns the logical OR of a and b
!
is executed first, then comes &&
and finally ||
Use parentheses instead of relying on operator precedence,
in order to make your code easier to read and understand.
false && false || true && true; // true
(false && false) || (true && true); // true
a + b // returns the sum of its operands
a - b // returns the difference of its operands
a * b // multiply two numbers
a / b // divides the first operand by the second operand
a % b // returns the remainder of the division
a < b // return true if a is less-than b, false otherwise
a > b // return true if a is greater-than b, false otherwise
a <= b // return true if a is less-than-or-equal-to b, false otherwise
a >= b // return true if a is greater-than-or-equal-to b, false otherwise
a === b // returns true if a is equals to b, false otherwise
a !== b // returns true if a is not equals to b, false otherwise
conditional_expression ? true_case : false_case;
if conditional_expression
is true
then returns true_case
value
else returns false_case
value
var a = 5;
var b = 6;
var max = (a > b) ? a : b; // max is 6
variable = value // assigns value to variable
variable += value // variable = variable + value
variable -= value // variable = variable - value
variable *= value // variable = variable * value
variable /= value // variable = variable / value
variable %= value // variable = variable % value