0

I often define an array like this:

var arr = new Array();

But when my PM saw my code, my PM said that I should define an array like this:

var arr = [];

and it will be more efficient. I find that there is another defined way var arr = ();?

What is the difference between them and which way do you often use?

4
  • 4
    What is var arr = (); ? Commented Aug 17, 2014 at 4:33
  • 1
    Best parctice is to use var arr = []; instead of var arr = new Array(); because Array object can be overwritten in JavaScript, but the array literal can't Commented Aug 17, 2014 at 4:35
  • @SubodhGhulaxe, Array object can be overwritten to what?Can you give me an example? Commented Aug 17, 2014 at 4:37
  • 1
    this question is already here stackoverflow.com/questions/2280285/… Commented Aug 17, 2014 at 4:53

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.