
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 6710 Articles for Javascript

4K+ Views
In this tutorial, we will learn how to get the exponent power of a number in JavaScript. The power of a number can be termed as how many times a particular number is multiplied by the number itself. For calculating the power of a number, we require two things, Base and Exponent. At the same time, a Base is a number that must be multiplied. Exponent (Usually written in the superscript) determines the number of times the number (Base) should be multiplied by itself. While we represent the power of a number using "^" or superscript when typing it, we ... Read More

1K+ Views
To calculate the area and perimeter of a circle, you can try to run the following code −Example JavaScript Example function Calculate(r) { this.r = r; this.perimeter = function () { return 2*Math.PI*this.r; }; this.area = function () { return Math.PI * this.r * this.r; }; } var calc = new Calculate(5); document.write("Area of Circle = ", calc.area().toFixed(2)); document.write("Perimeter of Circle = ", calc.perimeter().toFixed(2));

222 Views
A regular expression is an object that describes a pattern of characters. The JavaScript RegExp class represents regular expressions, and both String and RegExp define methods that use regular expressions to perform powerful pattern-matching and search-and-replace functions on the text.A regular expression could be defined with the RegExp () constructor, as follows −var pattern = new RegExp(pattern, attributes); or simply var pattern = /pattern/attributes;The following are the parameters −pattern − A string that specifies the pattern of the regular expression or another regular expression.attributes − An optional string containing any of the "g", "i", and "m" attributes that specify global, ... Read More

13K+ 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

287 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

436 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

477 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

11K+ 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

232 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 );

414 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 );