Is there a built-in JavaScript isnumeric function similar to jQuery’s isNumeric() to check if a value is a number?

I know jQuery provides an isNumeric() method to check if a value is an integer or number. Is there something similar in pure JavaScript that I can use without relying on jQuery?

I’ve worked a lot with legacy codebases that still use jQuery, and this comes up often. While there isn’t a native javascript isnumeric function, you can get pretty close using coercion with isNaN() and parseFloat().

function isNumeric(value) {
  return !isNaN(value) && !isNaN(parseFloat(value));
}

This behaves much like jQuery’s isNumeric, it checks if a value can be treated as a number. Super handy when parsing user input where numbers might come in as strings.

Yeah, I’ve bumped into issues with loose checks before, especially when values like "123" pass, but we actually wanted real number types. If you need a stricter javascript isnumeric check, go with this instead:”*

function isNumeric(value) {
  return typeof value === "number" && Number.isFinite(value);
}

This ensures you’re only accepting proper numeric types (not numeric-looking strings). It’s perfect for avoiding sneaky type coercion bugs in stricter codebases or APIs.

In my experience working on front-end validation, especially in forms, sometimes even typeof checks aren’t enough. If you’re specifically targeting numeric strings with decimal support, a regex-based javascript isnumeric check is my go-to.

function isNumeric(value) {
  return typeof value === "string" && /^[+-]?(\d+\.?\d*|\.\d+)$/.test(value.trim());
}

This catches valid numeric strings with or without decimals, but filters out anything funky like "12a". Great when you want tight validation without bringing in any libraries.