Skip to content

Comment on You Can't JavaScript Under Pressureparent

Comments

TIL there is no typeof === 'array'. -_-

    [] 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"})
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.