1 # disallow `Array` constructors (no-array-constructor)
3 Use of the `Array` constructor to construct a new array is generally
4 discouraged in favor of array literal notation because of the single-argument
5 pitfall and because the `Array` global may be redefined. The exception is when
6 the Array constructor is used to intentionally create sparse arrays of a
7 specified size by giving the constructor a single numeric argument.
11 This rule disallows `Array` constructors.
13 Examples of **incorrect** code for this rule:
16 /*eslint no-array-constructor: "error"*/
23 Examples of **correct** code for this rule:
26 /*eslint no-array-constructor: "error"*/
30 new Array(someOtherArray.length)
37 This rule enforces a nearly universal stylistic concern. That being said, this
38 rule may be disabled if the constructor style is preferred.
42 * [no-new-object](no-new-object.md)
43 * [no-new-wrappers](no-new-wrappers.md)