0

Array(10) is used here to generate an array of numbers.

Array.from(Array(10).keys());

What is this function?: Array()

Where can I find documentation on it?

2

1 Answer 1

1

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array#Syntax

new Array(arrayLength)

If the only argument passed to the Array constructor is an integer between 0 and 232-1 (inclusive), this returns a new JavaScript array with its length property set to that number (Note: this implies an array of arrayLength empty slots, not slots with actual undefined values). If the argument is any other number, a RangeError exception is thrown.

So Array.from(Array(n).keys()) is shorthand for "Create a new array of numbers 0 to n - 1".

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.