-1

is this:

var arr = {};

the same as

var arr = new Array();

?

5 Answers 5

7

It is not the same.

var arr = {};

initializes an object. If you want an array:

var arr = [];
Sign up to request clarification or add additional context in comments.

1 Comment

4

not exactly. var arr = []; is more like it.

Comments

2

No.

var arr = {}; // creates a new object with no properties

But

var arr = []; // creates a new blank array

Comments

1

var arr = {}; creates object

Comments

1

No, it's not: You're confusing array literals

var arr = []; // same as new Array()

with object literals

var obj = {}; // same as new Object()

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.