The following code:Array.from({length: 5}, (v, i) => i);
returns the following array [0, 1, 2, 3, 4]
Are there any other conditions you can include in the curly braces? (for example to change the value of the initial element or the step of the sequence)
array#map
.{length: 5}
is not a "condition" it's an array-like that can be used to generate a new array of similar length. That's it. If you include a positive integer property which is within bounds (e.g.,{0: "hello", 1: "world", length: 5}
then you'd get that as the first parameter of the callback (v
in this case).