Reduce in JavaScript | array.reduce() | How reduce works?

Поделиться
HTML-код
  • Опубликовано: 5 окт 2024

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

  • @abduxaliljunior8871
    @abduxaliljunior8871 5 месяцев назад +1

    Best bro ! Your video very sample for learn with your created animation !

  • @clydegrey5060
    @clydegrey5060 2 года назад +1

    An example that shows reduce summing an array of number disguises the true power of this method. You can use reduce to return an new array, an obejct, set, or whatever else you like. All of those are also single values. A single value does not mean solely a primitive type. I would consider adding that clarification so that learners won't be held back by a misconception.

    • @zorefcode
      @zorefcode  2 года назад +1

      Thank you for your time to respond. Single value doesn't mean to be primitives, but for the simplicity i just used this example. Thanks for pointing out this clyde grey.

  • @thekwoka4707
    @thekwoka4707 2 года назад +1

    Another good use is getting the element from an array that has the highest value of some prop.
    Since you can get the highest with less comparisons than using sort.

    • @zorefcode
      @zorefcode  2 года назад +1

      Yes reduce performs faster than sort. Thanks theKWOKA :)

  • @CaliburPANDAs
    @CaliburPANDAs 2 года назад +1

    Please explain what recursion is. thanks

    • @zorefcode
      @zorefcode  2 года назад +2

      Sure Panda Pete :)