0

hello i a m learning the javascript and I am wondering whether you can help me understand why there are two ways to make a new array?

From book I see the author is using:

var myArray = new Array("one","two",3);

Also seeing on the web

var myArray = ["one","two",3];

Can someone please explain to me what is the difference?

2
  • From my understanding, they are the exact same, just a preference on which one you like better. Commented Dec 20, 2015 at 2:23
  • With array literals, the VM knows we want an array; with new Array, the VM needs to use extra CPU cycles to figure out what new Array actually does. stackoverflow.com/a/7375418/1837472 Commented Dec 20, 2015 at 2:32

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.