Found 10877 Articles for Web Development

How to get the tangent of a number in JavaScript?

Shubham Vora
Updated on 14-Sep-2022 08:50:08

274 Views

In this tutorial, we will learn how to get the tangent of a number in JavaScript. The tangent of an angle is defined by the ratio of the length of the opposite side to the length of the adjacent side. It can also be defined as the ratio of sine and cosine function of an acute angle where the value of cosine function should not be zero. Mathematically, ๐‘ก๐‘Ž๐‘›๐œƒ=๐‘™๐‘’๐‘›๐‘”๐‘กโ„Ž ๐‘œ๐‘“ ๐‘กโ„Ž๐‘’ ๐‘œ๐‘๐‘๐‘œ๐‘ ๐‘–๐‘ก๐‘’ ๐‘ ๐‘–๐‘‘๐‘’ / ๐‘™๐‘’๐‘›๐‘”๐‘กโ„Ž ๐‘œ๐‘“ ๐‘กโ„Ž๐‘’ ๐‘Ž๐‘‘๐‘—๐‘Ž๐‘๐‘’๐‘›๐‘ก ๐‘ ๐‘–๐‘‘๐‘’ also, tanฮธ=(๐‘ ๐‘–๐‘›๐‘’ ๐‘œ๐‘“ ๐‘กโ„Ž๐‘’ ๐‘Ž๐‘›๐‘”๐‘™๐‘’ ๐œƒ)โ„(๐‘๐‘œ๐‘ ๐‘–๐‘›๐‘’ ๐‘œ๐‘“ ๐‘กโ„Ž๐‘’ ๐‘Ž๐‘›๐‘”๐‘™๐‘’ ๐œƒ) Where ๐œƒ = acute angle in radian The tangent of ... Read More

How to get the square root of a number in JavaScript?

Shubham Vora
Updated on 31-Oct-2022 08:55:03

10K+ Views

In this tutorial, we will learn how to get the square root of a number in JavaScript in both ways. The square root of a number in JavaScript can be found in two ways โˆ’ Using Math.sqrt() Method By creating a Custom Function The square root of a number is a factor that, when multiplied by itself, gives the original number. For example, 10 is the square root of 100 because if you multiply 10 by itself (10*10), the result will be 100. Using the Math.sqrt() Method In JavaScript, The Math.sqrt() method is useful for finding the square ... Read More

How to get the sine of a number in JavaScript?

Smita Kapse
Updated on 19-Jun-2020 07:54:06

139 Views

To get the sine of a number, use the JavaScript sine() technique. The sin technique returns a numeric value between -1 and one, that represents the sine of the argumentExampleYou can try to run the following code to get the sine of a number in JavaScript โˆ’ ย  ย  ย  ย  ย  JavaScript Math sin() Method ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย var value = Math.sin( 0.5 ); ย  ย  ย  ย  ย document.write("First Value : " + value ); ย  ย  ย  ย  ย  ย  ย  ย  ย  ย var value = Math.sin( 90 ); ย  ย  ย  ย  ย document.write("Second Value : " + value ); ย  ย  ย  ย  ย 

How to get a pseudo-random number between 0 and 1 in JavaScript?

usharani
Updated on 19-Jun-2020 07:53:05

303 Views

To get a pseudo-random number between 0 and 1, use the Math.random() method in JavaScript.ExampleYou can try to run the following code to get a pseudo-random number between 0 and 1 โˆ’ ย  ย  ย  ย  ย  JavaScript Math random() Method ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย var value = Math.random( ); ย  ย  ย  ย  ย document.write("First Value : " + value ); ย  ย  ย  ย  ย value = Math.random( ); ย  ย  ย  ย  ย document.write("Second Value : " + value ); ย  ย  ย  ย  ย 

How to get the smallest of zero or more numbers in JavaScript?

Shubham Vora
Updated on 26-Aug-2022 13:18:43

487 Views

In this tutorial, we shall learn to find the smallest among numbers in JavaScript. Letโ€™s discuss the available methods one after the other Using the Math.min() Method Here, the Math.min() is a static function of the placeholder object Math. If no parameters, the result is -Infinity. If the parameters are numbers, the result is the smallest among them. If any one of the parameters is not a number, the method returns NaN. This is an ECMAScript1 feature. Syntax Following is the syntax of Math.min() method โˆ’ Math.min(a1, a2, โ€ฆan) Here, we need to give numbers as parameters. Parameters ... Read More

How to get the largest of zero or more numbers in JavaScript?

Shubham Vora
Updated on 26-Aug-2022 13:07:28

207 Views

In this tutorial, we will look at how to get the largest of zero or more numbers in JavaScript. The maximum of multiple numbers can be found using different techniques. The first technique we will introduce is the Math.max() method. The second technique will be the for-loop method. Following are the methods to get the largest of zero or more numbers in JavaScript โˆ’ Using the Math.max() Method We can use the Math.max() method to find the largest of many numbers. It returns the largest value from the given multiple values. The input parameters should be numbers or can ... Read More

How to get the natural logarithm (base E) of a number in JavaScript?

Shubham Vora
Updated on 14-Sep-2022 08:36:43

264 Views

In this tutorial, we will learn how to get the natural logarithm of a number in JavaScript using Math.log() and Math.LN methods Since finding out the natural logarithm of a number through calculation is difficult, the methods like Math.log() and Math.LN is considered useful in JavaScript. You can use these methods not only in finding the length of a number in JavaScript but also while creating a calculation method for a number. Using the Math.log() Method The natural logarithm method is used to find a logarithm of a number with the base E. Compared to Math.LN method, while using Math.log() ... Read More

How to get the largest integer less than or equal to a number in JavaScript?

Shubham Vora
Updated on 15-Sep-2022 12:23:02

501 Views

In this tutorial, we will learn how to get the largest integer that can be less than or equal to a number in JavaScript. To get the largest integer less than or equal to a number, we use the Math.floor() method in JavaScript. It is used to round off a number supplied as a parameter to its closest integer towards the downward direction of rounding, i.e., towards the less significant value. Following are two ways in which we find the largest integer that can be less than or equal to a number in JavaScript. Using Math.floor() Method The method Math.floor() ... Read More

How can I specify the base for Math.log() in JavaScript?

Shubham Vora
Updated on 14-Jul-2022 12:56:27

546 Views

In this tutorial, we will learn to calculate the logarithm of any number value and specify the base for the Math.log() method.The logarithmic operation of mathematics is beneficial in many places. For example, if you want to show the graph representation for billions of values, it is hard to render on the screen. For that, we change the scale of the graph using the logarithm, and it becomes easy to generate and visualize the output for any particular operation.There can be many more examples where we can use the logarithmic function.Calculate the log using the Math.log()Specify different bases for Math.log()Specify ... Read More

How to calculate the ln of a given number in JavaScript?

vanithasree
Updated on 19-Jun-2020 07:31:41

2K+ Views

To calculate the ln of a given number, use the Math.log() method in JavaScript. This method returns the natural logarithm (base E) of a number. If the value of a number is negative, the return value is always NaN.ExampleYou can try to run the following code to get the ln of a given number โˆ’ ย  ย  ย  ย  ย  JavaScript Math log() Method ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  ย var value = Math.log(2); ย  ย  ย  ย  ย document.write("Value : " + value ); ย  ย  ย  ย  ย 

Advertisements