1.

Numbers and Mathematics in JavaScript

Answer»

JavaScript provides various properties and methods to deal with Numbers and Maths. Let us have a quick look at those:



  • Numbers Properties:


    • MAX VALUE — The maximum numeric value that JavaScript can represent.


    • NaN — The "Not-a-Number" value is NaN.


    • NEGATIVE INFINITY – The value of Infinity is negative.


    • POSITIVE INFINITY – Infinity value that is positive.


    • MIN VALUE — The smallest positive numeric value that JavaScript can represent.




  • Numbers Methods:


    • toString() — Returns a string representation of an integer.


    • toFixed() — Returns a number's string with a specified number of decimals.


    • toPrecision() — Converts a number to a string of a specified length.


    • valueOf() — Returns a number in its original form.


    • toExponential() — Returns a rounded number written in exponential notation as a string.




  • Maths Properties:


    • E — Euler's number is E.


    • SQRT1_2 — 1/2 square root


    • SQRT2 stands for square root of two.


    • LOG2E — E's base 2 logarithm


    • LN2 — The natural logarithm of 2 is LN2.


    • LN10 — The natural logarithm of ten is LN10.


    • LOG10E — E's base ten logarithm


    • PI — PI stands for Pianistic Integer.




  • Maths Methods:


    • exp(x) — Ex's value


    • floor(x) — x's value rounded to the nearest integer.


    • log(x) — The natural logarithm (base E) of x is log(x).


    • abs(x) — Returns the value of x in its absolute (positive) form.


    • acos(x) — In radians, the arccosine of x.


    • asin(x) — In radians, the arcsine of x.


    • pow(x,y) — x to the power of y


    • random() — Returns a number between 0 and 1 at random.


    • round(x) — Rounds the value of x to the nearest integer.


    • sin(x) — The sine of x is sin(x) (x is in radians)


    • sqrt(x) — x's square root


    • tan(x) — The angle's tangent


    • atan(x) is the numeric value of the arctangent of x.


    • atan2(y,x) — Arctangent of its arguments' quotient


    • ceil(x) — x's value rounded to the next integer


    • cos(x) – The cosine of x is cos(x) (x is in radians)


    • max(x,y,z,...,n) — Returns the highest-valued number.


    • min(x,y,z,...,n) — The number with the lowest value is the same as the number with the highest value.






Discussion

No Comment Found