Do you know what will be the output of this code?
JavaScript
console.log(Array.from({ length: 3 }, (_, i) => i * 2));
Show answer and explanation
The answer is [0, 2, 4].
{ length: 3 } is an array-like object with three empty slots. Array.from calls the map function for each index, and i * 2 gives 0, 2, 4.