JavaScript Array Reduce

Sdílet
Vložit
  • čas přidán 14. 05. 2018
  • JavaScript Array Reduce
    🔥Get the COMPLETE course (83% OFF - LIMITED TIME ONLY): bit.ly/2KZea52
    Subscribe for more videos:
    / @programmingwithmosh
    Want to learn more from me? Check out my blog and courses:
    programmingwithmosh.com
    / programmingwithmosh
    / moshhamedani

Komentáře • 368

  • @haroldcjennettiii
    @haroldcjennettiii Před 4 lety +94

    Once again Mosh shows why he's one of the best coding teachers. You make things very clear, because you explain what EVERYTHING is, in laymen's terms. A lot of coding teachers forget they're teaching beginners.

  • @albatros280
    @albatros280 Před 5 lety +451

    Finally... Somebody who explains reduce well. MDN documentation didn't help me.

  • @johnisutsa1641
    @johnisutsa1641 Před 5 lety +2

    How am I only finding your tutorials now. You explain so well. I'm taking you with me for the rest of my Java script journey.

  • @nashpaints
    @nashpaints Před 4 lety

    Been looking high and low for a simple explanation of the reduce method, and only now I have found it. Thank you.

  • @RetroRick1990
    @RetroRick1990 Před 4 lety +7

    Awesome , just understand what is the role of the "Accumulator" and the "Current Value" makes everything very clear. Thank man!

  • @glantzdesign6239
    @glantzdesign6239 Před 5 lety +1

    Thank you Mosh. I wish everyone can explain things as clearly as you.

  • @onyeukwuhycient438
    @onyeukwuhycient438 Před 2 lety +1

    This is by far the clearest explanation I've seen on the reduce method so far.. Thanks a lot Mr Mosh..

  • @mariodmp
    @mariodmp Před 5 lety +2

    This is super detailed, yet simple to understand, just great!

  • @gilbertrosario8633
    @gilbertrosario8633 Před 6 lety +1

    Great tutorial, very well explained and easy to follow, I can finally say I understand the reduce method. Thanks you! Hope to see more tutorials like this in the future, like this key word, classes, call, bind, apply, etc.

  • @preciousayobamiolagade4284

    Boss more blessing to you, love from Nigeria. You just explained all MDN couldn't in minutes

  • @harwinderthakur9708
    @harwinderthakur9708 Před 4 lety +8

    I spent 20 minutes on mdn understanding all this. I got more confused there.Thanks man

  • @tung01vuongtri33
    @tung01vuongtri33 Před 2 lety +1

    finally, I can totally understand the reduce method thanks to you, appreciate your channel

  • @millertime6
    @millertime6 Před 5 lety +1

    Took me a while to get reduce even after learning all the other iteration methods. Thank you!

  • @clarinetisfying
    @clarinetisfying Před 2 lety +4

    I love he teaches coding very clearly in a short amount of time. He's the best coding teacher.

    • @msh1830
      @msh1830 Před rokem

      czcams.com/video/a_Bfu1XWGmI/video.html

  • @jame_sta
    @jame_sta Před 5 lety +1

    You're the BEST Instructor I've ever come across +ProgrammingwithMosh
    *sheds a tear* LOL :D -- I can't wait for more JS videos!!!!!

  • @MatchesMaloneThe3rd
    @MatchesMaloneThe3rd Před 3 lety +1

    Cleanest explanation I've seen so far. You just earned yourself a sub.

  • @Nessquickable
    @Nessquickable Před 5 lety +2

    Hadn't got used to that reduce method and was struggling for a while, only took me a minute of your explanation to spark a lightbulb in my head and I felt relieved. Thank you.

    • @msh1830
      @msh1830 Před rokem

      czcams.com/video/a_Bfu1XWGmI/video.html

  • @JeffThePoustman
    @JeffThePoustman Před 5 lety +2

    Thank you, Mosh. I found this very helpful for grasping the concept of reduce().

  • @EnricMartin1987
    @EnricMartin1987 Před rokem

    Thank you Mosh. This is one of the best explanations about how to use reduce, that I could find on CZcams.

  • @shayanfaghihi
    @shayanfaghihi Před 2 lety

    I've explored every single line of MDN reference, but I didn't learn as much I could get from you. Appreciate that mate

  • @bobthehuntsman1548
    @bobthehuntsman1548 Před 3 lety

    Thank you so much for this tutorial! Love the no-nonsense approach that any layman can pick up on :)

  • @WanBarmawi
    @WanBarmawi Před 2 lety

    The English is just so perfect for a non-native speaker like me. The explanation is so easy to understand too. Thank you so much, you get my subscription!

  • @CrydonPT
    @CrydonPT Před 3 lety

    Thank you for explaining this right! No one seems to explain the first callback value as the accumulator but yet as the previous value.

  • @zdargahi
    @zdargahi Před 5 lety +68

    It would be great if you explain how the accumulation can be an array or object, and how when instead of chaining map and filter we can use reduce. I guess it's in the complete course.

    • @liamwelsh5565
      @liamwelsh5565 Před 2 lety +1

      If you were using an array, you could return an array in the reduce, and spread the accumulator. Then add any new value after. Example:
      nums = [1,2,3,4,5]
      const doubledNums = nums.reduce( (acc, num) => [...acc, num*2], [ ])
      console.log(doubledNums) // [2,4,6,8,10]
      Obviosuly a .map could do the same thing but there are more complex examples where it is useful.

    • @Xetron1978
      @Xetron1978 Před rokem

      @@liamwelsh5565 Hi, I'm very new to coding, may I know why did you add the "..." before acc? I'm not really sure what it does here

    • @liamwelsh5565
      @liamwelsh5565 Před rokem +4

      @@Xetron1978 … is the spread operator. If you have an array, let’s call x and want to make a new array, let’s call y, that has all the values of x, you can spread x into y.
      Example:
      Const x = [1,2,3]
      Const y = […x]
      Console.log(y)
      // [1,2,3]
      You can also spread objects into objects

  • @alvarosena858
    @alvarosena858 Před 2 lety

    This video is posted a long time ago, but for the first time i understand reduce. Thanks Mosh!

  • @slickchick8292
    @slickchick8292 Před 2 lety +1

    Mosh, thank you so much! You broke this down into a very easy to understand way.

  • @demiansims728
    @demiansims728 Před 5 lety

    This was VERY helpful and clear. Thanks, Mosh

  • @timilehinoni
    @timilehinoni Před 3 lety

    By far the best explanation of reduce I have gotten haven watch tones of videos and tutorials

  • @ayromo7
    @ayromo7 Před 4 lety

    Excellent explanation. I was confused how it worked until I saw this. Keep doing what you're doing man!

  • @travezripley
    @travezripley Před 5 lety +1

    Thank you Mosh!!! This ruled!!!

  • @rpb4865
    @rpb4865 Před 2 lety +17

    Can anyone explain why for loop or foreach is "old way" and reduce is more "elegant way"?
    I find the"old way" more readable than the "elegant way"

    • @hamdiboujarra
      @hamdiboujarra Před 2 lety

      understand the elegant way and use the readable way if you want, after some months you will like to use the elegant way

    • @mikaelhelin6348
      @mikaelhelin6348 Před 2 lety +1

      I also think the "old way" is better. The "elegant way" is limited to iteration of type y_n = f(y_{n-1}, x_n) where f is the callback function. There is this new movement in programming where people think old fashion for-loops are ugly code.

  • @user-yz6jf5vv6h
    @user-yz6jf5vv6h Před 4 lety

    Hooray, finally someone explained normally .. thank you very much!

  • @bevedel
    @bevedel Před 3 lety

    After watching this higher education, I was finally able to deeply understand it. Thank you!

  • @niwanthakaweragoda9480

    Man, amazing explanation! So much better than some of the videos and websites I have seen on this topic!

  • @Gamer-gw6nj
    @Gamer-gw6nj Před rokem

    The first tutorial that made me understand reduce method. Thanks.

  • @sandoxs
    @sandoxs Před 5 lety

    wonderful explanation!!! tnx for been there Mosh!!!

  • @muhammadsultanularafin8846

    Wow! Explained in a super easy way. Thank you.

  • @jasonkowens6820
    @jasonkowens6820 Před 6 lety +2

    Excellent breakdown as usual, cool new js feature

  • @toantruong9203
    @toantruong9203 Před 5 lety

    Easy and simple, thank you!

  • @atinukeodunsi2208
    @atinukeodunsi2208 Před 5 lety

    This is soooo helpful. Thanks Mosh!

  • @olumorsotnas
    @olumorsotnas Před rokem

    Best code videos I ever watched. Thank you brother!

  • @hebahamdi3855
    @hebahamdi3855 Před 4 lety +1

    Thank you for making js clear and simple to understand

  • @marygracegardner2843
    @marygracegardner2843 Před 2 lety

    Thank you dude, this is incredible. I wasn't understanding this before watching your video, thank you.

  • @TheRodrigocabral
    @TheRodrigocabral Před 4 lety

    That's exactly what I needed. Thanks.

  • @mustafaalawad2667
    @mustafaalawad2667 Před 5 lety

    Thank you so much, wonderful explain

  • @furn2313
    @furn2313 Před 2 lety

    Mosh is everything a newbie needs!!!

  • @kudafoolhu
    @kudafoolhu Před 4 lety

    Thank you. Better than any video out there.

  • @rajabmuhamedrajab5128
    @rajabmuhamedrajab5128 Před 3 lety +1

    Finally ... some who explain reduce well .Thanks

  • @JayloAbdullahi
    @JayloAbdullahi Před 5 lety

    Thank you very much for making this clear!

  • @dioncadiz
    @dioncadiz Před 4 lety

    Best method of teaching reduce method from complicated to its simplest possible form all under 10mins. You are amazing good sir. Thank you

  • @whynologin
    @whynologin Před 4 lety

    Thank you sir for explaining this so clearly.

  • @stoatanasov
    @stoatanasov Před 5 lety

    Thank you very much for this explanation . It was really useful. Keep up the good work.

  • @augustineonyekachiadmiora9015

    Finally!!! Well explained in details. You’re a good man

  • @newsha71
    @newsha71 Před 4 lety

    Thank you so much. This was such a huge help!

  • @beedev5197
    @beedev5197 Před 5 lety

    It was really clear explanation. Thanks a lot Mosh!

  • @ahnaafarafee
    @ahnaafarafee Před 3 lety

    I was totally in the dark with this Reduce thing...thanks for explaining🙏 great help 👏👏👏

  • @milec7092
    @milec7092 Před 3 lety

    Wow, so clear. Thanks, Mosh!!

  • @Phoenix24Leas
    @Phoenix24Leas Před 4 lety +6

    This is nice but it'd be great if there was something on how to use reduce when making new objects/arrays

  • @danbrown4781
    @danbrown4781 Před 3 lety

    Great vid , helped me to finally jump that mental hurdle.

  • @ill-fatedstranger447
    @ill-fatedstranger447 Před 6 lety

    Quite Good tutorial with some good examples how actually reduce works. Keep it up

  • @vedatsozen
    @vedatsozen Před 2 lety

    Thank really. I was making a project. I am adding tips of bills as % to a calculation machine and i need to sum all tips and print. At the end i succeeded by looking to your tutorial. Thanks so much.

  • @xomgitsjay
    @xomgitsjay Před 3 lety

    Wow, so I was trying to understand this by reading it on MDN and it was just not sinking in. This helped SO much! Thank you good sir.

  • @diegodmitry
    @diegodmitry Před 3 lety

    I'm from Brazil, but you explained so well. Thanks a lot!

  • @mavs4life248
    @mavs4life248 Před 4 měsíci

    Thank you for breaking this down in detail. Very easy to understand.

  • @ibrahimkedir5713
    @ibrahimkedir5713 Před 3 lety

    Cheers, nice way of explaining things, I always pass ur videos when it pop ups now I watch and it's wonderful.

  • @surajitdas6555
    @surajitdas6555 Před 5 lety

    Simply superb!!!

  • @RameenFallschirmjager
    @RameenFallschirmjager Před 4 lety

    Very well explained, thank you!

  • @drunkbutsober18
    @drunkbutsober18 Před 2 lety

    Awesome explanation! Thank you for this!

  • @farhanshahriar1072
    @farhanshahriar1072 Před 3 lety

    Thanks man! It helps me a lot.

  • @NITESHSINGHNRS
    @NITESHSINGHNRS Před 5 lety +1

    Best... Thank you sir...love from india.♥️

  • @martinlipinski1403
    @martinlipinski1403 Před rokem

    You are a king in easy explaining

  • @justinlangley1056
    @justinlangley1056 Před 3 lety

    Literally just spent an hour trying to figure this out from reading on MDN. I understood beforehand how reducing works. I'm familiar with the concept from a few other languages, which implement it more elegantly through lambda expressions. Javascript syntax can be odd at first, and it all came down to simple syntax errors I was making.

  • @lindyscolors
    @lindyscolors Před rokem

    This helped me so much, thank you!!!

  • @Chief_Sir_E.C.O._Nwuju
    @Chief_Sir_E.C.O._Nwuju Před rokem +1

    Thank you so much brother,your explanation was very simple and clear

  • @justafterdark1177
    @justafterdark1177 Před 5 lety

    You are the best, man. Thanks!

  • @psawyer871
    @psawyer871 Před 5 lety +2

    thank you so much!

  • @md.bulbulislam2326
    @md.bulbulislam2326 Před 2 lety

    Thank you so much for the beautiful explanation of reduce the method.

  • @longtranbao4177
    @longtranbao4177 Před 3 lety

    Wow very clearly. Many thanks

  • @alessandrosebastiani8021

    Very helpfull and clear as well in the explaination MDN was making me crazy. Thanks mosh! :)

  • @RedBricksTraffic
    @RedBricksTraffic Před 2 lety +1

    Having it explained in video form is so much easier for me than reading it. Thank you!

    • @msh1830
      @msh1830 Před rokem

      czcams.com/video/a_Bfu1XWGmI/video.html

  • @andriyfm
    @andriyfm Před 6 lety

    I love it, easy to learn

  • @journeysalgado2972
    @journeysalgado2972 Před rokem

    This made my brain hurt a lot less than the lesson I was reading. Thank you!

  • @sanyogyadav3913
    @sanyogyadav3913 Před 2 lety

    thanks buddy for making concept clear

  • @readingplaylists495
    @readingplaylists495 Před 3 lety

    You explain very well. Thanks!

  • @ritsk4338
    @ritsk4338 Před 4 lety

    Great video on reduce(). Thankyou you have clear all my queries and doubts

  • @raphaeltaglialegna9668

    Nice class, thanks for this content!

  • @aviranweb
    @aviranweb Před 4 lety

    Tnx Mosh for perfect explanation

  • @wanderimwangi73
    @wanderimwangi73 Před 2 lety

    you have made it simple man ! kudos

  • @orlandolinhares6610
    @orlandolinhares6610 Před 3 lety

    very well explained, congratz !

  • @michaelrosenfeld8055
    @michaelrosenfeld8055 Před 3 lety

    Thank you for this awesome explanation!

  • @faisalahmed9434
    @faisalahmed9434 Před 4 lety

    you are an amazing teacher!!

  • @code_fu552
    @code_fu552 Před 5 lety +1

    Amazing!!! Thank u for breaking it down and explaining the components . Very helpful.

    • @msh1830
      @msh1830 Před rokem

      czcams.com/video/a_Bfu1XWGmI/video.html

  • @anthimonebrahim9507
    @anthimonebrahim9507 Před 3 lety

    thanks, for your clear explanation

  • @carlosduque8767
    @carlosduque8767 Před 3 lety

    This was great! thank you

  • @vikaskad5737
    @vikaskad5737 Před rokem

    one of the best explaination I ever watched

  • @biplob9764
    @biplob9764 Před 3 lety

    You are awesome Mosh!!

  • @Developerorium
    @Developerorium Před 2 lety

    simple and great explanation Mosh.

  • @BURN-ADDiCT
    @BURN-ADDiCT Před 2 lety

    Nicely explained, thank you

  • @valtallica
    @valtallica Před 3 lety

    Dude this is the best. Thanks.

  • @BrandonSWie
    @BrandonSWie Před 4 lety

    Hi, Mosh. It was really helpful. Thanks.