Check If Type Is Int Javascript Code Example


Example 1: javascript check if a value is an int

// The Number.isInteger() checks to see if the passed value is an integer // Returns true or false  Number.isInteger(2); //True Number.isInteger(90); //True Number.isInteger("37"); //False Number.isInteger(false); //false

Example 2: javascript check if a value is a integer number

Number.isInteger(123) //true Number.isInteger(-123) //true Number.isInteger(5-2) //true Number.isInteger(0) //true Number.isInteger(0.5) //false Number.isInteger('123') //false Number.isInteger(false) //false Number.isInteger(Infinity) //false Number.isInteger(-Infinity) //false Number.isInteger(0 / 0) //false

Example 3: js is variable int

// The === operator is used for checking // the value and the type of a variable  var data = 1;  if (data === parseInt(data, 10))     alert("data is integer") else     alert("data is not an integer")

Comments

Popular posts from this blog

Chemistry - Bond Angles In NH3 And NCl3

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Change The Font Size Of Visual Studio Solution Explorer