DEV Community

Discussion on: Top 26 JavaScript Interview Questions I Wish I Knew

Collapse
 
leo profile image
Leonardo Galante

Great article!

For "Q11: How would you check if a number is an integer?" I recommend using:

function isInt(num) {
  return Number.isInteger(num)
}

console.log(isInt(4)); // true
console.log(isInt(12.2)); // false
console.log(isInt(0.3)); // false
Enter fullscreen mode Exit fullscreen mode
Collapse
 
6temes profile image
Daniel

As far as you are not tageting IE.

caniuse.com/#search=isInteger