Javascript - Integer

About

Integer aren't implemented in javascript, only double exists. See Javascript - Number (Double)

With integers, you have to take care that all calculations fit within the range between –2^53 and 2^53, but you don’t have to worry about rounding errors.

Be careful

There is no integer in javascript but float

var myNumber = 0.1 + 0.2 

console.log("myNumber is not 0.3 but " + myNumber) 

From

String

parseInt with a string and a base

parseInt(string,base)

Example

let i = parseInt("5.01",10); // 5
if (i>=5){
  console.log(`i (${i}) is greater or equal to 5`);
} else {
  console.log(`i (${i})  is less than 5`);
}

Powered by ComboStrap