4

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

1

1 Answer 1

6

Yep, both are objects:

typeof []; // "object"
typeof new Array(); // "object"
Sign up to request clarification or add additional context in comments.

2 Comments

FWIW, typeof null === "object" too. A bug since the beginning of JavaScript.
and typeof NaN === "number" when NaN clearly states that it is Not A Number. JavaScript !!!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.