Suggest an editImprove this articleRefine the answer for “typeof []”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)The **`typeof`** operator in JavaScript returns **the type of a value** as a string, but for an array it returns `"object"`, **not** `"array"`. **Key point:** an array is a special case of an object, so `typeof []` always gives `"object"`.Shown above the full answer for quick recall.Answer (EN)ImageThe `typeof` operator in JavaScript returns **the type of a value** as a string. But it has one **non-obvious behavior** - with arrays. --- ## Example: ```javascript console.log(typeof []); // "object" ``` Yes, an array returns `"object"` - **not** `"array"`. --- ## Why is that? Because in JavaScript **an array is a special case of an object**. Internally it is implemented as an object, where: - the **keys** are numeric indexes (`"0"`, `"1"`, `"2"`), - and the `length` property tracks the number of elements. Example: ```javascript const arr = ["a", "b"]; console.log(Object.keys(arr)); // ["0", "1"] ``` --- ## How to correctly check that it is actually an array Use: ```javascript Array.isArray([]); ``` or ```javascript [] instanceof Array; ``` Both options return: ```javascript true ``` --- ## In short: | Check | Returns | Comment | |---|---|---| | `typeof []` | `"object"` | because an array is an object | | `Array.isArray([])` | `true` | the correct way | | `[] instanceof Array` | `true` | also correct, but depends on the environment | --- > **Summary:** > `typeof []` -> `"object"` > because arrays are **special objects**, optimized for storing ordered data.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.