JavaScript Math.abs()
Esempio
let x = Math.abs(-7.25);
Definizione e utilizzo
Il Math.abs()
metodo restituisce il valore assoluto di un numero.
Altri esempi
let a = Math.abs(7.25);
let b = Math.abs(-7.25);
let c = Math.abs(null);
let d = Math.abs("Hello");
let e = Math.abs(2-3);
Supporto browser
Math.abs()
è una funzione ECMAScript1 (ES1).
ES1 (JavaScript 1997) è completamente supportato in tutti i browser:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |
Sintassi
Math.abs(x)
Parametri
Parameter | Description |
x | Required. A number. |
Valore di ritorno
Un numero che rappresenta il valore assoluto del numero specificato. r NaN se il valore non è un numero. 0 se il valore è null . |