Skip to content

Commit

Permalink
Update index.md (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
VinayKrMittal authored Sep 2, 2023
1 parent f2a129e commit cf2a913
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion posts/154-fill-array/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ If you'd like to create an array initialized with primitive values, then the bes
To create an array initialized with object instances, and you don't care that each item would have the same object instance,
then `Array(length).fill(initialObject)` is the way to go.

Otherwise, to fill an array with different object instances you could use `Array.from(Array.length, mapper)` or `[...Array(length)].map(mapper)`, where `mapper` is a function
Otherwise, to fill an array with different object instances you could use `Array.from(Array(length), mapper)` or `[...Array(length)].map(mapper)`, where `mapper` is a function
that returns a new object instance on each call.

*What other ways to fill an array in JavaScript do you know?*

0 comments on commit cf2a913

Please sign in to comment.