JavaScript forEach vs. map - When To Use Each and Why

Поделиться
HTML-код
  • Опубликовано: 7 сен 2024
  • In today's video, let's compare the Array forEach method with map in JavaScript, and talk about when it's appropriate to use one or the other.
    For your reference, check this out:
    developer.mozi...
    developer.mozi...
    🏫 My Udemy Courses - www.udemy.com/...
    🎨 Download my VS Code theme - marketplace.vi...
    🐦 Find me on Twitter - / dcodeyt
    💸 Support me on Patreon - / dcode
    📰 Follow me on DEV Community - dev.to/dcodeyt
    📹 Join this channel to get access to perks - / @dcode-software
    If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!
    #dcode #javascript

Комментарии • 12

  • @sruthisivakumar5682
    @sruthisivakumar5682 Месяц назад

    Clear difference sited out when and where to use it

  • @isaacadigbli8184
    @isaacadigbli8184 Месяц назад

    Bro you are full of wisdom. Cos Your contents are more than gold. Keep up the good work bro🇬🇭🇬🇭

    • @dcode-software
      @dcode-software  Месяц назад

      Appreciate it man thanks for watching 🙏

  • @oabdulazeez
    @oabdulazeez Месяц назад

    Thank You sir!
    Please what theme do you use in VSCode?

    • @dcode-software
      @dcode-software  Месяц назад

      It's my theme. Search for "dcode" on VS Code Extensions Marketplace

  • @TomasMisura
    @TomasMisura Месяц назад

    i am old school guy, still iterating using old but good for :) But I personally feel that i would need modernize myself :)

    • @dcode-software
      @dcode-software  Месяц назад +1

      Yeah just add "map" to your code if you're doing array transformations.

    • @TomasMisura
      @TomasMisura Месяц назад

      @@dcode-software OK, I'll do it.

    • @christian-schubert
      @christian-schubert Месяц назад

      Careful though, these are NOT the same things!
      Whereas forEach and map perform a function on each item of your data, a for loop does what the name implies, looping over your data. Consequently, the behavior WILL be different, for instance when fetching data, etc.

  • @jmmmmmmmmmk
    @jmmmmmmmmmk Месяц назад

    U explain this stuff very very well
    You should do udemy courses

    • @dcode-software
      @dcode-software  Месяц назад +1

      Thank you. I actually do have a few Udemy courses but maybe I should do some more 😎

  • @j-lewis
    @j-lewis Месяц назад

    Your name Dom like Dominic or DOM like Document Object Model? Haha, jk, good stuff there, thanks!