JS: Math (namespace)
What is the Keyword βMathβ
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 vector (1,1) console.log(Math.hypot(1, 1)); // 1.4142135623730951 // length of 3d vector (1,1,1) console.log(Math.hypot(1, 1, 1)); // 1.7320508075688772
Math[Symbol.toStringTag]-
(new in ECMAScript 2015)
value is the string
"Math".