23 lines
686 B
Markdown
23 lines
686 B
Markdown
---
|
||
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) |