showing results for - "create javascript array with 1 value"
Alberto
12 Jul 2016
1let arr = [42]       // Creates an array with only one element:
2                     // the number 42.
3
4let arr = Array(42)  // Creates an array with no elements
5                     // and arr.length set to 42.
6                     //
7                     // This is equivalent to:
8let arr = []
9arr.length = 42
10