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.