Array literals should always be preferred to Array constructors.
Array constructors are error-prone due to the way their arguments are interpreted. If more than one argument is used, the array length will be equal to the number of arguments. However, using a single argument will have one of three consequences:
For these reasons, if someone changes the code to pass 1 argument instead of 2 arguments, the array might not have the expected length. To avoid these kinds of weird cases, always use the more readable array.
var a1 = new Array(x1, x2, x3); // Noncompliant. Results in 3-element array. var a2 = new Array(x1); // Noncompliant and variable in results var a3 = new Array(); // Noncompliant. Results in 0-element array.
var a1 = [x1, x2, x3]; var a2 = [x1]; var a3 = [];