Use Number.isFinite() to check for a number in JavaScript

Need the best way to check for a number in JavaScript while excluding NaN or Infinity? Try Number.isFinite() instead of typeof.

Hi Octavian Theodor Nita, thanks for reminding me to take another look at Sumer Singh’s response — number.isFinite() is great!

Photo by Karina Carvalho on Unsplash

🤓 The physical therapist who writes JavaScript 💪 Web Developer 😎 Mentor 🧠 DPT 😄 SEO Expert 😁 React 😆 Jamstack 💬 Ask me anything 👉 DoctorDerek.com 👈

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store