Math.PI
Math.PI
속성은 원의 둘레와 지름의 비율, 약 3.14159의 값을 가집니다.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
Property attributes of Math.PI |
|
---|---|
Writable | no |
Enumerable | no |
Configurable | no |
설명
PI
는 Math
의 정적 속성이므로, 사용자가 생성한 Math
객체의 속성으로 접근할 수 없고 항상 Math.PI
를 사용해야 합니다. (Math
는 생성자가 아닙니다)
예제
Math.PI
사용하기
다음 함수는 Math.PI
를 사용해 주어진 원의 반지름에서 둘레를 계산합니다.
function calculateCircumference(radius) {
return Math.PI * (radius + radius);
}
calculateCircumference(1); // 6.283185307179586
명세
사양 | 등급 | 주석 |
---|---|---|
ECMAScript 1st Edition (ECMA-262) | Standard | Initial definition. Implemented in JavaScript 1.0. |
ECMAScript 5.1 (ECMA-262) The definition of 'Math.PI' in that specification. |
Standard | |
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Math.PI' in that specification. |
Standard | |
ECMAScript (ECMA-262) The definition of 'Math.PI' in that specification. |
Living Standard |
브라우저 호환성
BCD tables only load in the browser