How to check if a value is a number in JavaScript?
Use Number.isFinite() for usable numbers, or typeof plus Number.isNaN() when Infinity is fine. Includes numeric string checks and a comparison table.
466 posts about JavaScript: questions with answers, tutorials and articles, newest first.
Use Number.isFinite() for usable numbers, or typeof plus Number.isNaN() when Infinity is fine. Includes numeric string checks and a comparison table.
A TypeScript function type is written (a: number) => string. See aliases, call signatures, optional parameters, generics, overloads and utility types.
A type of element can mean a JavaScript data type or a DOM element type. This guide covers typeof, instanceof, nodeType and input types.
Use typeof value === "string" to detect string primitives in JavaScript, and learn how String wrapper objects, empty strings and TypeScript guards change the check.
typeof, Array.isArray, instanceof and Object.prototype.toString each answer a different question. See which one to use and which pitfalls to avoid.
Check the type of any JavaScript value with typeof, Array.isArray(), instanceof and Object.prototype.toString, and learn the quirks to watch for.
Learn how to check the type of an array item with typeof and instanceof, and how to identify DOM elements with tagName, nodeType, matches and instanceof.
JavaScript has seven primitive types and one object type. This guide covers each type, typeof results, and the difference between value and reference.
Learn which JavaScript check to use for each data type: typeof for primitives, Array.isArray for arrays, instanceof for classes, and a toString helper for everything.
Inside a function, typeof arguments is object, because arguments is array-like but not an array. Learn conversion, rest parameters and arrow function limits.
JavaScript functions are written as declarations, expressions or arrow functions. See how they differ in hoisting, this binding and constructors, with examples.
typeof returns lowercase "string" for string primitives, but "object" for String wrapper objects. Examples and safe string checks.
See all eight values typeof can return in JavaScript, why typeof null is object, and better checks for arrays, null and classes.
typeof returns "function" for every callable value, classes included. See the full list of typeof results and how to guard callbacks.
typeof returns the string function for every callable value, from arrow functions to classes. Learn the full typeof table and safe callback checks.
typeof undefined returns the string undefined, even for undeclared names. See when values are undefined and how to check for it in modern JavaScript.
Use typeof, instanceof, Array.isArray and Object.hasOwn to check whether a variable, class or property exists in JavaScript, and avoid the null and TDZ traps.
Use typeof for primitives, then add checks for null, arrays and objects. Includes instanceof, Object.prototype.toString and a reusable getType helper.
Compare typeof to a type-name string inside an if statement. Learn every return value and how to handle null, arrays, NaN and undeclared variables.
Object is JavaScript's only non-primitive type, and arrays, functions, dates and RegExp are all objects. See how references, copying and comparison differ.