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.

Math.SQRT2 プロパティは、 1/2 の平方根、約 0.707 を表します。

試してみましょう

function getRoot1Over2() {
  return Math.SQRT1_2;
}

console.log(getRoot1Over2());
// Expected output: 0.7071067811865476

𝙼𝚊𝚝𝚑.𝚂𝚀𝚁𝚃𝟷_𝟸=120.707\mathtt{Math.SQRT1_2} = \sqrt{\frac{1}{2}} \approx 0.707
Math.SQRT1_2 のプロパティ属性
書込可能不可
列挙可能不可
設定可能不可

解説

Math.SQRT1_2 は定数であり、 Math.sqrt(0.5) と同等でよりパフォーマンスの高いものです。

SQRT1_2Math オブジェクトの静的プロパティなので、 Math オブジェクトを生成してプロパティとして使用するのではなく、常に Math.SQRT1_2 として使用するようにしてください (Math はコンストラクターではありません)。

Math.SQRT1_2 の使用

以下の関数は 1 を 2 の平方根で割った値を返します。

js
function getRoot1_2() {
  return Math.SQRT1_2;
}

getRoot1_2(); // 0.7071067811865476

仕様書

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

ブラウザーの互換性

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
SQRT1_2

Legend

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

Full support
Full support

関連情報