This is a new technology, part of the ECMAScript 2015 (ES6) standard.
This technology's specification has been finalized, but check the compatibility table for usage and implementation status in various browsers.
O método Number.isInteger() determina se o valor passado é um inteiro.
Sintaxe
Number.isInteger(valor)
Parâmteros
valor- O valor a ser testado por ser um inteiro.
Descrição
Se o valor a ser testado for um inteiro, retorna true, senão retorna false. Se o valor for NaN ou infinito, retorna false.
Exemplos
Number.isInteger(0.1); // false
Number.isInteger(1); // true
Number.isInteger(Math.PI); // false
Number.isInteger(-100000); // true
Number.isInteger(NaN); // false
Number.isInteger(0); // true
Number.isInteger("10"); // false
Polyfill
Number.isInteger = Number.isInteger || function(value) {
return typeof value === "number" &&
isFinite(value) &&
Math.floor(value) === value;
};
Especificações
| Especificação | Estado | Comentário |
|---|---|---|
| ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Number.isInteger' in that specification. |
Standard | Definição inicial. |
Compatibilidade dos browsers
| Funcionalidade | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Suporte básico | (Yes) | 16 (16) | Not supported | (Yes) | Not supported |
| Funcionalidade | Android | Chrome para Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
| Suporte básico | Not supported | Not supported | 16.0 (16) | Not supported | Not supported | Not supported |
Ver também
- O objecto
Numberao qual pertence.
Etiquetas do documento e colaboradores
Etiquetas:
Colaboradores para esta página:
Redeagle48
Última atualização por:
Redeagle48,