# Math.abs() Method with Example in JavaScript

JavaScript | Math.abs() Method: Here, we are going to learn about the abs() method of Math class in JavaScript with Examples.
Submitted by Shivang Yadav, on December 06, 2019

## JavaScript | Math.abs() Method

Math operations in JavaScript are handled using functions of math library in JavaScript. In this tutorial on Math.abs() method, we will learn about the abs() method and its working with examples.

Math.abs() is a function in math library of JavaScript that is used to find the absolute value of the given number.

Syntax:

```    Math.abs(value);
```

Parameter(s):

• value – It represents the value whose absolute value to be found.

Return value:

The return type of this method is number, it returns the absolute value of the given value.

Examples 1: Valid inputs of the method

```console.log(Math.abs(98))
console.log(Math.abs(-34.56))
console.log(Math.abs("-65"))
```

Output

```98
34.56
65
```

Example 2: Input values that are invalid

```console.log(Math.abs("Include Help"))
console.log(Math.abs([45, 65, 576]))
console.log(Math.abs([]))
```

Output

```NaN
NaN
0
```

TOP Interview Coding Problems/Challenges

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates