- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 8895 Articles for Front End Technology
316 Views
The following are some of the Math Functions in JavaScript −S.NoMethod & Description 1abs()Returns the absolute value of a number.2acos()Returns the arccosine (in radians) of a number.3asin()Returns the arcsine (in radians) of a number.4atan()Returns the arctangent (in radians) of a number.5atan2()Returns the arctangent of the quotient of its arguments.6ceil()Returns the smallest integer greater than or equal to a number.ExampleLet’s see an example of abs() Math function in JavaScript. The Math() function returns the absolute value of a number − JavaScript Math abs() Method var ... Read More
313 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
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
149 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 );
318 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 );
532 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
223 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
299 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
543 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
598 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