0

I understand about JavaScript spread syntax in general. But in the following code, I cannot understand why it is used when creating a new array of specific length:

const createArray = length => [...Array(length)];
VLAZ
  • 26,331
  • 9
  • 49
  • 67
  • Have you tried comparing the result with e.g. `length => Array(length)`? It should quickly become obvious why you generally don't want that. – jonrsharpe Apr 06 '23 at 17:10
  • @VLAZ yes, it does. It has all the explanations I needed. Thanks a lot to you and other members. Happy coding to all. – Zonaed Hasan Apr 06 '23 at 17:21

0 Answers0