freeCodeCamp/guide/chinese/javascript/standard-objects/math/index.md

23 lines
686 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
title: Math
localeTitle: 数学
---
## 数学
`Math`是JavaScript的标准内置对象包含数学常量和函数作为属性和方法。最值得注意的是它包含常量π和Euler常量以及诸如`floor()` `round()` `ceil()`等函数。
### 例
以下示例显示如何使用`Math`对象编写计算圆的面积的函数:
```javascript
function calculateCircleArea(radius) {
return Math.PI * Math.pow(radius, 2);
}
calculateCircleArea(1); // 3.141592653589793
```
### 其他资源
* [MDN网络文档](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math)
* [W3Schools的](https://www.w3schools.com/js/js_math.asp)