Is map faster than a for loop in JavaScript? (no, but sometimes yes)

Поделиться
HTML-код
  • Опубликовано: 25 дек 2024
  • github.com/tom...

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

  • @SNSISNSJISEJSJS
    @SNSISNSJISEJSJS Год назад +2

    This dude never lets me disappointed

  • @fikrirahmatnurhidayat4988
    @fikrirahmatnurhidayat4988 Год назад +1

    You drop this video in the perfect time due, I'm just about to benchmark those two approach haha. Thanks.

    • @fikrirahmatnurhidayat4988
      @fikrirahmatnurhidayat4988 Год назад

      Wait I though, map, Map or Hashtable (POJO) things haha. But this still cools tho.

    • @tomontheinternet
      @tomontheinternet  Год назад

      Yeah. Why do the function and data structure have the same name???

  • @jungervin8765
    @jungervin8765 3 месяца назад

    I am confused... You are not calculating in the array creation time for the map. Why? No, map can' be faster, map should be always slower!! Come on! 65 likes and no one noticed this? The loop obviously slower, because you creating a new array. And pushing items to the array with overindexing like array[nonexistent]=1 I am not sure it is a great idea, I would've used array.push.