A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Math/PI below:

Math.PI - JavaScript | MDN

Math.PI

Baseline Widely available

Math.PI 静态数据属性表示圆的周长与直径的比例,其值约为 3.14159。

尝试一下
function calculateCircumference(radius) {
  return 2 * Math.PI * radius;
}

console.log(Math.PI);
// Expected output: 3.141592653589793

console.log(calculateCircumference(10));
// Expected output: 62.83185307179586
值 𝙼𝚊𝚝𝚑.𝙿𝙸 = π ≈ 3.14159 \mathtt{Math.PI} = \pi \approx 3.14159 可写 否 可枚举 否 可配置 否 描述

由于 PI 是 Math 的静态属性,因此应始终使用 Math.PI,而不是作为你创建的 Math 对象的属性(Math 不是构造函数)。

示例 使用 Math.PI

以下函数使用 Math.PI 来计算给定半径的圆周长。

function calculateCircumference(radius) {
  return Math.PI * (radius + radius);
}

calculateCircumference(1); // 6.283185307179586
规范 浏览器兼容性 参见

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4