Math.PI
A propriedade Math.PI
representa a proporção entre circunferência de um círculo com o seu diâmetro, aproximadamente 3.14159:
Experimente
Property attributes of Math.PI |
|
---|---|
Writable | no |
Enumerable | no |
Configurable | no |
Descrição
Como PI
é uma propriedade estática de Math
, sempre use-a como Math.PI
, ao invés de uma propriedade de um objeto Math
que você criou (Math
não é um construtor).
Exemplos
Usando Math.PI
A seguinte função usa Math.PI
para calcular a circunferência de um círculo com um dado raio.
function calcularCircunferencia(raio) {
return 2 * Math.PI * raio;
}
calcularCircunferencia(1); // 6.283185307179586
Especificações
Specification | Status | Comment |
---|---|---|
ECMAScript 1st Edition (ECMA-262) | Padrão | Definiçao inicial. Implementado no JavaScript 1.0. |
ECMAScript 5.1 (ECMA-262) The definition of 'Math.PI' in that specification. |
Padrão | |
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Math.PI' in that specification. |
Padrão | |
ECMAScript (ECMA-262) The definition of 'Math.PI' in that specification. |
Padrão em tempo real |
Compatibilidade com navegadores
BCD tables only load in the browser