fill Array Method | JavaScript Tutorial
Вставка
- Опубліковано 10 лют 2025
- 👉 Daily Coding Challenges: iCodeThis.com/...
In this tutorial we're going to learn about the #fill #JavaScript #Array Method and how it can be used to change the elements inside of an array with a specific value. Optionally we can provide a start and an end index.
JS Array Methods Playlist: • JavaScript Array Methods
---
Support my channel:
💜 Become a Member of the Poppers Family and receive special perks: ua-cam.com/users/fl...
💜 Donate via StreamLabs: streamlabs.com...
💜 Donate via PayPal: paypal.me/flor...
💜 Become a patron: / florinpop17
Thank you! 🙏
---
👨👩👧👦 Join the Discord family: / discord
---
Follow me on:
📃 Website/Blog: florin-pop.com
👉 Twitter: / florinpop1705
👉 Linkedin: / florinpop17
👉 Instagram: / florinpop17
👉 Facebook: / florinpop17
👉 Github: github.com/flo...
👉 Dev.to: dev.to/florinp...
👉 Twitch: twitch.com/flo...
Check out the other videos in the JavaScript Array Methods series: ua-cam.com/play/PLgBH1CvjOA62PBFIDq55-S6Beivje30A2.html
An other solution that I like better is the from() static method of Array.
The first argument is any iterable, like an array, a string or an object. So you can specify an object with unique property length. The second argument is just a callback that maps each element of the newly created Array.
const fillInNumbers = n => Array.from({ length: n }, (_, i) => i)
Great explanation, good job
superb🔥🔥🙏
Hi Florin Pop. I have one question. What is the _ for first argument in map method?
It’s just a placeholder as we don’t need that parameter
@@FlorinPop thank you👍🏼
I'm confused, we are adding numbers in this part (indx + 1). Why are we creating "items" as numbers instead of an empty length of spaces? I mean we are working with de index parameter not the item. Hope you can understand my question.
thx
I have a small doubt here... instead of [ 1, 2, 3 ]...I need [ { num : 1 }, { num : 2 } ]...is there any way ??
Yes, what ever you return in the map will be inside the array
what is "Array" inside the function