JavaScript Number.isInteger ()

Il metodo JavaScript Number.isInteger () determina se il valore passato è un numero intero.

La sintassi del isInteger()metodo è:

 Number.isInteger(value)

Il isInteger()metodo viene chiamato utilizzando il Numbernome della classe.

Parametri Number.isInteger ()

Il isInteger()metodo comprende:

  • valore - Il valore da verificare per essere un numero intero.

Valore restituito da Number.isInteger ()

  • Restituisce un che Booleanrappresenta se il valore dato è un numero intero.

Nota : I isInteger()metodo restituisce falseper NaNe Infinity.

Esempio: utilizzo di Number isInteger ()

 console.log(Number.isInteger(453)); // true console.log(Number.isInteger(-44)); // true console.log(Number.isInteger(5.0)); // true console.log(Number.isInteger(456.129)); // false console.log(Number.isInteger(Math.PI)); // false console.log(Number.isInteger(NaN)); // false console.log(Number.isInteger(Infinity)); // false console.log(Number.isInteger("10")); // false console.log(Number.isInteger(true)); // false console.log(Number.isInteger(false)); // false console.log(Number.isInteger((1))); // false

Produzione

 vero vero vero falso falso falso falso falso falso falso falso

Articoli interessanti...