Parameters or Arguments
number The wide variety to convert to an absolute value.
The abs() function returns the absolute price of a number.
If the abs() characteristic is handed a non-numeric value, an array with one than one element, or an empty object as the range parameter, the abs() function will return NaN (not a number).
The abs() function will try to convert the quantity parameter to a numeric price before calculating the absolute value. Math is a placeholder object that consists of mathematical functions and constants of which abs() is one of these functions.
console.log(Math.abs(-23)); console.log(Math.abs('-23')); console.log(Math.abs(-30 * 2));
In this example, we have invoked the abs() characteristic the use of the Math class.
We have written the output of the abs() characteristic to the internet browser console log, for demonstration purposes, to exhibit what the abs() function returns.
The following will be output to the web browser console log:
23 23 60
In this example, the first output to the console log lower back 23 which is the absolute cost of -23. The 2d output to the console log also returned 23 after first changing the string fee ‘-23’ to the numeric fee -23 and then calculating its absolute value. The third output to the console log back 60 which is the absolute price of the calculation of -30 x 2