- 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 8907 Articles for Front End Technology
12K+ Views
This tutorial will teach us to convert negative numbers to positive ones. Sometimes, programmers need to perform some operation with the unsigned value of the number, and in such a case, they need to convert the negative numbers to positive numbers. We will go through the various methods to convert a negative number to a positive number in this tutorial. Using the Math.abs() Method Multiplying the negative number with -1 Using the Bitwise Not Operator Using the Math.abs() Method The Math.abs() method is the JavaScript math library method. The Math.abs() method takes a value as a parameter and ... Read More
154 Views
In this guide, we will explain the different methods to do basic maths with JavaScript operators. While creating any website, application, or game, you might have to show the calculated results, whether the number shows the subscriber count or the points of the user. Hence, learning how to add, subtract, and multiply using different data types in JavaScript is important. Using (+) Operator for Addition in JavaScript The binary operator to do basic maths in JavaScript is straightforward. However, the process can become a bit complex when you have to get the number as the output. This method will teach ... Read More
313 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
304 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
145 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 );
311 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 );
517 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
214 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
284 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
To Continue Learning Please Login
Login with Google