create dobule asus in javascript in javascript

To create a double Array in JavaScript, you can use the Array.from() method or the spread operator. Here's an example using the Array.from() method:

index.tsx
const doubleArray = Array.from({ length: 2 }, () => []);

console.log(doubleArray); // [[], []]
96 chars
4 lines

The above code creates an Array of length 2 and fills each element with a new empty Array.

Alternatively, you can use the spread operator to create the double Array:

index.tsx
const doubleArray = [[], [...[]]];

console.log(doubleArray); // [[], []]
74 chars
4 lines

Here, we're creating a new empty Array and then using the spread operator to create a second element which is also an empty Array.

gistlibby LogSnag