Const arr new array

A new array!

In JavaScript, you can create a new array using the following methods:

  1. Literal notation: const arr = [];
  2. Array constructor: const arr = new Array();
  3. Array.from(): const arr = Array.from();
  4. Spread operator: const arr = [...];

Here's an example of each method:

Literal notation

const arr = [];
console.log(arr); // Output: []

Array constructor

const arr = new Array();
console.log(arr); // Output: []

Array.from()

const arr = Array.from();
console.log(arr); // Output: []

Spread operator

const arr = [...];
console.log(arr); // Output: []

Note that the spread operator is not a direct way to create an empty array, but you can use it to create a new array from an existing array or an iterable.

Which method do you prefer?