Math.SQRT2

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

Die statische Daten-Eigenschaft Math.SQRT2 repräsentiert die Quadratwurzel von 2, ungefähr 1.414.

Probieren Sie es aus

function getRoot2() {
  return Math.SQRT2;
}

console.log(getRoot2());
// Expected output: 1.4142135623730951

Wert

𝙼𝚊𝚝𝚑.𝚂𝚀𝚁𝚃𝟸=21.414\mathtt{Math.SQRT2} = \sqrt{2} \approx 1.414
Eigenschaften von Math.SQRT2
Schreibbarnein
Aufzählbarnein
Konfigurierbarnein

Beschreibung

Math.SQRT2 ist eine Konstante und eine leistungsstärkere Alternative zu Math.sqrt(2).

Da SQRT2 eine statische Eigenschaft von Math ist, verwenden Sie sie immer als Math.SQRT2 und nicht als Eigenschaft eines von Ihnen erstellten Math-Objekts (Math ist kein Konstruktor).

Beispiele

Verwendung von Math.SQRT2

Die folgende Funktion gibt die Quadratwurzel von 2 zurück:

js
function getRoot2() {
  return Math.SQRT2;
}

getRoot2(); // 1.4142135623730951

Spezifikationen

Specification
ECMAScript® 2025 Language Specification
# sec-math.sqrt2

Browser-Kompatibilität

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
SQRT2

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

Siehe auch