Hacker News new | ask | show | jobs
by dclowd9901 4635 days ago
TIL there is no typeof === 'array'. -_-
3 comments

    [] instanceof Array; // returns true
However this fails on "Array-like" objects like NodeLists.
Clever...
Array.isArray(yourVariable), yeah, had to mdn that one too.
typeof(["an array", "contains multiple things"]) == typeof(["sometimes"])
Yes, but:

    typeof(["an array", "contains multiple things"]) == typeof({but_this_one: "is an object"})