JS: Math (namespace)
What is the Keyword βMathβ
Math is the value of the property key "Math" of the Global Object
.
console.assert(globalThis["Math"] === Math);
Type
console.assert(typeof Math === "object");
Parent
Parent of Math is Object.prototype.
console.assert(Reflect.getPrototypeOf(Math) === Object.prototype);
Purpose
Purpose of Math object is as a namespace for math related functions and constants.
Properties
- JS: Math. max, min
- JS: Math. sign, abs
- JS: Math ceiling, floor, round, truncate
- JS: Math. random
- JS: Power and Roots
- JS: Math exponential and logarithm
- JS: Math constants. pi, e, sqrt, etc.
- JS: Math trig functions. sin, cos, tan, asin, acos, atan
- JS: Math hyperbolic functions. sinh, cosh, tanh, etc.
- JS: Math fround, clz32, imul
Misc
Math.hypot(x1, x2, etc)-
(new in ECMAScript 2015)
Return the square root of
(x1^2 + x2^2 + etc^2). This is useful to compute the length of a higher dimension vector in linear algebra.// length of 2d unit vector console.log(Math.hypot(1, 1)); // 1.4142135623730951 // length of 3d unit vector console.log(Math.hypot(1, 1, 1)); // 1.7320508075688772
Math[Symbol.toStringTag]-
(new in ECMAScript 2015)
value is the string
"Math".
JavaScript. math functions.
- JS: Math (namespace)
- JS: Math. max, min
- JS: Math. sign, abs
- JS: Math ceiling, floor, round, truncate
- JS: Math. random
- JS: Power and Roots
- JS: Math exponential and logarithm
- JS: Math constants. pi, e, sqrt, etc.
- JS: Math trig functions. sin, cos, tan, asin, acos, atan
- JS: Math hyperbolic functions. sinh, cosh, tanh, etc.
- JS: Math fround, clz32, imul
JavaScript. Number
- JS: Number
- JS: Number Input. Binary, Hexadecimal, Octal, Etc
- JS: BigInt tutorial
- JS: Assignment Operators
- JS: Arithmetic Operators
- JS: Number Comparison Operators
- JS: Convert String and Number
- JS: Convert Decimal, Hexadecimal
- JS: Convert Decimal, Binary
- JS: Format Number
- JS: Random Integer Range Function π
- JS: Number (class)
- JS: Number Constructor
- JS: Number.prototype
- JS: Math (namespace)