Math.SQRT1_2
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 Dateneigenschaft Math.SQRT1_2
repräsentiert die Quadratwurzel von 1/2, was ungefähr 0,707 entspricht.
Probieren Sie es aus
function getRoot1Over2() {
return Math.SQRT1_2;
}
console.log(getRoot1Over2());
// Expected output: 0.7071067811865476
Wert
Eigenschaften von Math.SQRT1_2 | |
---|---|
Schreibbar | nein |
Aufzählbar | nein |
Konfigurierbar | nein |
Beschreibung
Math.SQRT1_2
ist eine Konstante und eine leistungsfähigere Alternative zu Math.sqrt(0.5)
.
Da SQRT1_2
eine statische Eigenschaft von Math
ist, wird sie immer als Math.SQRT1_2
verwendet, anstatt als Eigenschaft eines selbst erstellten Math
-Objekts (Math
ist kein Konstruktor).
Beispiele
Verwendung von Math.SQRT1_2
Die folgende Funktion gibt 1 über die Quadratwurzel von 2 zurück:
function getRoot1_2() {
return Math.SQRT1_2;
}
getRoot1_2(); // 0.7071067811865476
Spezifikationen
Specification |
---|
ECMAScript® 2025 Language Specification # sec-math.sqrt1_2 |
Browser-Kompatibilität
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
SQRT1_2 |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support