JavaScript Math.sqrt()
Beispiel 1
let x = Math.sqrt(9);
Definition und Verwendung
Die Methode Math.sqrt() gibt die Quadratwurzel einer Zahl zurück.
Beispiel 2
let a = Math.sqrt(0);
let b = Math.sqrt(1);
let c = Math.sqrt(9);
let d = Math.sqrt(64);
let e = Math.sqrt(-9);
Browser-Unterstützung
Math.
ist eine ECMAScript1 (ES1)-Funktion.
ES1 (JavaScript 1997) wird in allen Browsern vollständig unterstützt:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |
Syntax
Math.sqrt(x)
Parameter
Parameter | Description |
---|---|
x | Required. A number |
Rückgabewert
Eine Zahl. Wenn x eine negative Zahl ist, wird NaN zurückgegeben. |