# JavaScript typeof Operator: Every Result and Its Quirks

DevFeed: [JavaScript typeof Operator: Every Result and Its Quirks](<https://devfeed.tech/articles/javascript-typeof-operator-every-result-and-its-quirks-109249.md>)

Original publisher: [Read original article](<https://markodenic.com/javascript-typeof/>)

Author: Marko

Published: 2026-10-30T09:00:00Z

Content type: article

Language: en

Sources: [Marko Denic Blog](<https://devfeed.tech/sources/marko-denic-blog.md>)

Topics: [JavaScript](<https://devfeed.tech/topics/javascript.md>)

Tags: [arguments](<https://devfeed.tech/tags/arguments.md>), [array](<https://devfeed.tech/tags/array.md>), [arrays](<https://devfeed.tech/tags/arrays.md>), [arrow](<https://devfeed.tech/tags/arrow.md>), [async](<https://devfeed.tech/tags/async.md>), [boolean](<https://devfeed.tech/tags/boolean.md>), [browser](<https://devfeed.tech/tags/browser.md>), [browsers](<https://devfeed.tech/tags/browsers.md>), [bug](<https://devfeed.tech/tags/bug.md>), [class](<https://devfeed.tech/tags/class.md>), [classes](<https://devfeed.tech/tags/classes.md>), [code](<https://devfeed.tech/tags/code.md>), [console](<https://devfeed.tech/tags/console.md>), [constructor](<https://devfeed.tech/tags/constructor.md>), [conversion](<https://devfeed.tech/tags/conversion.md>), [debugging](<https://devfeed.tech/tags/debugging.md>), [feature-detection](<https://devfeed.tech/tags/feature-detection.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [null](<https://devfeed.tech/tags/null.md>), [operator](<https://devfeed.tech/tags/operator.md>), [tutorial](<https://devfeed.tech/tags/tutorial.md>)

## AI overview

JavaScript's `typeof` operator returns one of eight strings and is most useful for checking primitive types and functions. Several results need special handling: `null` and arrays both return `"object"`, while `NaN` returns `"number"`; use direct equality for `null`, `Array.isArray()` for arrays, and `Number.isNaN()` or `Number.isFinite()` for numeric checks. `typeof` can safely check undeclared variables, though accessing `let` or `const` before declaration still throws. For more specific object types, the excerpt uses `Object.prototype.toString`; `instanceof` checks whether an object comes from a particular class or constructor. It also shows a finite-number guard for function arguments and notes that wrapper constructors such as `new String()` produce objects.

## Source excerpt

How typeof works in JavaScript: the 8 possible results, the famous quirks (typeof null, arrays, NaN), checking for undefined safely, and the right way to test for arrays, null and objects.