When to use literal array notation in JS?

Asked

Viewed 29 times

0

I started using the Jshint in my projects, together with the Sublime Linter (which, by the way, I recommend). After doing the setup I came across the following warning::

The literal array Notation is preferable

in a statement of the type:

var myArray = new Array();

Of course this is easily bypassed with:

var myArray = [];

I remember reading some reports about the performance of one or another notation, but nothing very concrete. I also read that at ES6, both would have exactly the same functionality. The question (or questions) is:

  • What is the difference between the ratings?
  • There is, in practical terms, a difference in performance between them?
  • There are edge cases where only one of the two would be the right one?
  • Which to use, after all?
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.