JS: Math Operators
Basic Arithmetic
// plus, add (3 + 4) === 7
// minus, substraction (3 - 4) === -1
// negation -(-3) === 3
// multiply 3 * 4 === 12
// divide 3 / 4 === 0.75
Remainder, Mod
7 % 2 === 1 7.4 % 2 === 1.4000000000000004 7 % 3.4 === 0.20000000000000018
Ceiling, Floor, Round
Math.floor(3.5847) === 3 Math.ceil(3.5847) === 4 Math.round(3.54) === 4 Math.round(3.55) === 4
Root, Power, Exponential
// power. JS2016 2 ** 3 === 8; // same as Math.pow(2, 3) === 8;
// square root Math.sqrt(4) === 2
// cube root Math.cbrt(8) === 2
// 4th root Math.pow(16, 1 / 4) === 2
JavaScript, Operators
JavaScript, Number
- JS: Number
- JS: Assignment Operators
- JS: Math Operators
- JS: Number Comparison Operators
- JS: Convert String, Number
- JS: Convert Decimal, Hexadecimal
- JS: Convert Decimal, Binary
- JS: Format Number
- JS: Random Integer Range Function π
- JS: Number Object
- JS: Number Constructor
- JS: Number.prototype
- JS: Math