JavaScript Math random() method18 Mar 2025 | 1 min read The JavaScript math random() method returns the random number between 0 (inclusive) and 1 (exclusive). SyntaxThe random() method is represented by the following syntax: ReturnThe random number between 0 (inclusive) and 1 (exclusive). JavaScript Math random() method exampleHere, we will understand random() method through various examples. Example 1Let's see an example to find out the random number between 0 and 1. Output: 0.9118351487222218 Example 2Let's see an example to find out the random number between two values. Output: 3.9030538241130746 Example 3Let's see an example to find out the random integer number between two values. Output: 3 Next TopicJavaScript Math |
JavaScript The JavaScript math asin() method returns the arcsine of the given number in the form of radians. The asin() method must be in the range -1 to 1, otherwise it returns NaN. Syntax The asin() method is represented by the following syntax: Math.asin(num) Parameter num - A number. Return The arcsine...
1 min read
JavaScript The JavaScript math sin() method returns the sine of the given number. The value returned by sin() method ranges between -1 to 1, which represents the sine of the angle. Syntax The sin() method is represented by the following syntax: Math.sin(num) Parameter num - A number. Return The sine of the...
1 min read
JavaScript The JavaScript math cos() method returns the cosine of the given number. The value returned by cos() method ranges -1 to 1, which represents the cosine of the angle. Syntax The cos() method is represented by the following syntax: Math.cos(num) Parameter num - A number. Return The cosine of a number. JavaScript...
1 min read
JavaScript The JavaScript math pow() method returns the base to the exponent power such as baseexponent. In other words, the base value (x) is multiplied with itself exponent times (y). Syntax The pow() method is represented by the following syntax: Math.pow(base,exponent) Parameter Base - The base number. Exponent - The number...
1 min read
JavaScript The JavaScript math cbrt() method returns the cube root of the given number. Unlike sqrt() method, this method accepts negative number. Syntax The cbrt() method is represented by the following syntax: Math.cbrt(num) Parameter num - A number. Return The cube root of the given number. JavaScript example Here, we will understand cbrt()...
1 min read
JavaScript The JavaScript math sign() method returns the sign of the number. It indicates whether the given number is positive, negative or zero. Syntax The sign() method is represented by the following syntax: Math.sign(num) Parameter num - A number. Return The sign of the given number. JavaScript example Here, we will understand sign()...
1 min read
JavaScript The JavaScript math exp() method returns the exponential form of the given number i.e. ex. Here, x is the argument and e is the base of natural algorithms. Syntax The exp() method is represented by the following syntax: Math.exp(num) Parameter num - A number. Return The number in the form of...
1 min read
JavaScript The JavaScript math max() method compares the given numbers and returns the maximum value. Syntax The max() method is represented by the following syntax: Math.max(num1,num2,....,numN) Parameter num1,num2,....,numN - Numbers to be compared.. Return A maximum value of the given numbers. JavaScript example Here, we will understand max() method through various examples. Example 1 Let's...
1 min read
JavaScript The JavaScript math sqrt() method returns the square root of a number. If the provided number is negative, it returns NaN. Syntax The sqrt() method is represented by the following syntax: Math.sqrt(num) Parameter num - A number. Return The square root of the given number. JavaScript example Here, we will understand sqrt()...
1 min read
JavaScript The JavaScript math tanh() method returns the hyperbolic tangent of the given number. Syntax The tanh() method is represented by the following syntax: The tanh() method is represented by the following syntax: Parameter num - A number. Return The hyperbolic tangent of a number. JavaScript example Here, we will understand tanh() method...
1 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India