Search code examples
javascriptarraysobjectlanguage-concepts

In Javascript is an array literal an object?


I'm reading the JavaScript The Definitive Guide and it says:

The easiest way to create an array is with an array literal

But then it says:

Another way to create an array is with the Array() constructor.

My question is, no matter how we declare an array in javascript, does it continue being an object? Thanks


Solution

  • Yep, both are objects:

    typeof []; // "object"
    typeof new Array(); // "object"