Convert ES6 Iterable to Array Convert ES6 Iterable to Array arrays arrays

Convert ES6 Iterable to Array


You can use Array.from or spread syntax (...).

Example:

const x = new Set([ 1, 2, 3, 4 ]);const y = Array.from(x);console.log(y); // = [ 1, 2, 3, 4 ]const z = [ ...x ];console.log(z); // = [ 1, 2, 3, 4 ]