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.SQRT1_2 属性表示 1/2 的平方根,约为 0.707:

Math.SQRT1_2=12=120.707\mathtt{\mi{Math.SQRT1_2}} = \sqrt{\frac{1}{2}} = \frac{1}{\sqrt{2}} \approx 0.707
Math.SQRT1_2 的属性特性
可写
可枚举
可配置

描述

由于 SQRT1_2Math 对象的静态属性,所以应该像这样使用: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

参见