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)];
2
  • Have you tried comparing the result with e.g. length => Array(length)? It should quickly become obvious why you generally don't want that. Commented Apr 6, 2023 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. Commented Apr 6, 2023 at 17:21

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.