JavaScript Array Map Method In 90 Seconds #JavaScriptJanuary

preview_player
Показать описание
Watch the entire #JavaScriptJanuary series from the beginning!

The JavaScript array map() method creates a new array from the results of a function called on each element in another array. And it does not modify the original array.

The new array is equal to the original array mapped to a function. The function is passed as an argument to map and is called on each element in the original array. The function has access to the current element, the index, as well as the entire original array.

In the body of the function, the goal is to compute a new value and then return it. We can also change this into an arrow function to further reduce the amount of code. So by using map, we achieve our goal using much less code than a for loop and without mutating the internal state.

Note that since map builds a new array, using it when you aren’t using the returned array is an anti-pattern. So you shouldn’t use the map method if you’re not using the array it returns, nor when you’re not returning a value from the callback. In these cases it would be better to use forEach() or a regular for loop instead.

I'll be releasing a new video every day in January! Stay tuned..
_____________________________________

📚 Learn to CODE in just a FEW months here:
_____________________________________

🛠️ Tools I use:

_____________________________________

💖 Show support!
_____________________________________

Watch Next:
_____________________________________

Connect With Me:
_____________________________________

** Affiliate Disclaimer: Some of the above links may be affiliate links, which may generate me a sales commission at no additional cost to you.

#JavaScriptJanuary #31Days31Videos #codeSTACKr
Рекомендации по теме
Комментарии
Автор

Thanks for all of the support! Stay tuned for a new video every day in January!!

Watch the entire #JavaScriptJanuary series from the beginning!

📚 My Favorite Web Design Books 📚
Web Design with HTML, CSS, JavaScript and jQuery Set by Jon Duckett (paid link)

codeSTACKr
Автор

I think a made that mistake a few times where I wasn't really returning anything out of the map method and realized if I wasn't really returning anything, then I'd be better off with forEach() . I love these series brother, keep it up! You deserve far more viewers, this is top notch content!

hectorserrano
Автор

Nice presentational videos...looking for more videos on all modern JS concepts..

rajeshsahu