DEV Community

loading...

Discussion on: Typeof array is an object in javascript

Collapse
lexlohr profile image
Alex Lohr

Class instances are also objects. An array literal is just an instance of the Array global constructor. Side note: overwriting the globalThis.Array/Object class can be (ab)used to steal data for example from JSONp responses.

If you want to know the actual type of the object, have a look at Object.prototype.toString.call(arr), which should result in [object Array].