English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The Mth.PI property represents the ratio of the circumference of a circle to its diameter, approximately.3.14159.
Since PI is a static property of Math, you always use it asMath.PI,not used as a property of the Math object created.
Math.PI
Math.PI;Test and see‹/›
All browsers fully support the Math.PI property:
Property | |||||
Math.PI | Yes | Yes | Yes | Yes | Yes |
Writable: | None |
---|---|
Enumerable: | None |
Configurable: | None |
Return Value: | The numerical representation of PI |
JavaScript Version: | ECMAScript 1 |
Calculate the circumference of a circle through the radius:
function getCircumference(radius) { return (2 * Math.PI * radius); } getCircumference(5);Test and see‹/›
Calculate the area of a circle through the radius:
function getArea(radius) { return (Math.PI * radius * radius); } getArea(5);Test and see‹/›