Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Hey! just studying creating Arrays in JS. What real world scenarios would 'new Array' be used instead of literal Array

(just curious)

2 Answers

I'm not sure there is any real world scenario where you would want to use new Array() over an array literal. I don't believe there is any type of performance benefit, and it is uneccessarily verbose.

Thanks Andrew

"A common error in JavaScript programs is to use an object when an array is required or an array when an object is required. The rule is simple: when the property names are small sequential integers, you should use an array. Otherwise, use an object." - Douglas Crockford