Learn JavaScript Array Reduce In 10 Minutes

Поділитися
Вставка
  • Опубліковано 1 січ 2025

КОМЕНТАРІ •

  • @rosseaton990
    @rosseaton990 2 роки тому +68

    This was the most simple and straight forward example of reduce I've seen. Thank you!

  • @kelseymovies
    @kelseymovies 2 роки тому +6

    Thank you for this! I just took a whole course about it and got even more confused. Your video broke it down to a point where it clicks.

  • @Vibestr
    @Vibestr 2 роки тому +12

    Another good reason to set the second parameter on the reduce is if you are totaling price on an object (like in your example) and you didn't set this parameter to 0, then total would represent the object (the first item in the array) and your code would error out. Thank you for this video Kyle.

  • @johnjoyce
    @johnjoyce 3 роки тому

    best explanation of reduce in javascript that i have ever seen. be cautious saying amunnuh when you mean “I’m going to”. that can be difficult for non native listeners

  • @ademlayes9116
    @ademlayes9116 Рік тому

    I've watched this video twice, once before ~5 months and now after forgetting what "reduce" does... and im so thankful every time! Thank you!

  • @_boza
    @_boza 2 роки тому +1

    I think you said the best definition of reduce ever. "Reduce, all it does. It takes array of values whatever that is and reduces it down to one single value"

  • @NaroTaro
    @NaroTaro 2 роки тому

    I've been stuck on understanding reduce for 2 days now. This video cleared everything up. Thanks!

  • @encapsule2220
    @encapsule2220 2 роки тому

    best explanation. my scalp is starting to regrow hair follicles thanks to u

  • @MrGodman1981
    @MrGodman1981 3 роки тому +33

    Last week I was struggling with aggregate of object attributes in an array of objects due to the missing intiial value of 0 and I learned it the hard way. Also I had the groupby use case well. Thanks for simplying groupBy.

  • @elie8181
    @elie8181 3 роки тому +3

    very good explanation of the reduce method, it is clear and simple.
    I'm a french developper in training and I understood everything, thank you and good continuation for your UA-cam channel

  • @alirezashahmoradi7648
    @alirezashahmoradi7648 2 роки тому +4

    I cant believe how you made it that simple. Thank you!!

  • @loumeroj
    @loumeroj 3 роки тому

    I'm at least watching the ads cause this guy explained reduce briefly and concisely :) and nice hair btw

  • @Sun-gk8fc
    @Sun-gk8fc Рік тому

    7 the video on reduce in the last 40 mins and this is as simple as you can get...superb. A like and a subscribe from me.

  • @freudinsky
    @freudinsky Рік тому

    LOL - after googling for HOURS(!!!) I finally got it - after just 3min into this video. Damn good explanation! Thank you sooo fkn much!!!

  • @donotlook6048
    @donotlook6048 3 роки тому

    This guy really uploaded this video 2 weeks ago and today I needed to use reduce and didn't know it worked, now i do thanks man. Whenever I need to understand something new I just type the concept + webdevsimplified and watch ur video lol

  • @TheDanthelion
    @TheDanthelion Рік тому

    While I understood how reduce worked, I didn't quite get why I kept hearing how powerful it was - your object example made it very clear in a short amount of time!

  • @Rift_131
    @Rift_131 2 роки тому

    Man, you helped me solve a problem that's been kicking my butt for a LONG time. THANK YOU!

  • @darklord8684
    @darklord8684 2 роки тому +1

    after your explanation this is my fav method

  • @scratchercatcher6760
    @scratchercatcher6760 3 роки тому

    Thank you VERY MUCH! All CLEAR NOW FOR ME and you made video without any extra "bloggers show off". My like to you and subscription.

  • @tanvirhasanmonir1627
    @tanvirhasanmonir1627 2 роки тому

    Thanks Kyle for your simplified explanation with useful example

  • @pcchamikara
    @pcchamikara 2 роки тому

    you REDUCED my effort of understanding the "reduce" function. 👌

  • @rafaXD05
    @rafaXD05 3 роки тому

    I was looking for resources to learn about `reduce` method. Your video came in as a rescue Kyle.. 😍
    You are a saviour!!

  • @InsertYourself1
    @InsertYourself1 Рік тому +2

    10 minutes of this is so much better than 1,000 hours of understanding the docs

  • @kunalmaloo8806
    @kunalmaloo8806 9 місяців тому

    best explaination i used for loop each time but now onwards i am shifting to reduce

  • @mayowasunusi9161
    @mayowasunusi9161 Рік тому

    Thank you Kyle, I saw .reduce in a TS tutorial, i had no idea how to do it, your video was straightforward

  • @vinicius2336SP
    @vinicius2336SP 2 роки тому +1

    Dude... you're amazing! Thanks a lot! You're so much better than my teacher LOL
    Thanks for your content! I'll be buying your course soon. :)
    Have a nice day!

  • @JamesJon1187
    @JamesJon1187 2 роки тому +1

    4:12

  • @beepybeepy4903
    @beepybeepy4903 Рік тому

    Thank you so much! This is so much clearer than other tutorails using acc, cur….

  • @johnadriandodge
    @johnadriandodge Рік тому

    Shalom Mr. K, outstanding explanation!
    Thank you
    Shalom

  • @nabilelidrissi8541
    @nabilelidrissi8541 Рік тому

    I've watched a fair few videos on reduce, but you have explained this wayyyy better.

  • @mr__info___
    @mr__info___ 2 роки тому

    You truly simplify the web. thank you!

  • @vivekmodi3165
    @vivekmodi3165 Рік тому

    The concept of reduce method is very well explained because it was difficult to understand the concept of this in the documentation.
    Thanks.

  • @eugene4296
    @eugene4296 10 місяців тому

    This is amazing, and really helpful. I have immediately subscribed. And I think I love you sir. :)

  • @odilanmaevidence9545
    @odilanmaevidence9545 2 роки тому

    All i gotta say is Thank you mate, you're awesome!

  • @filipcza2
    @filipcza2 Рік тому

    Thanks man! Been hating the tasks which force you to use reduce so far.. feels like you randomly try until it somehow works. I really don't get why this feels so awkward to use or understand but your examples were extremely clear and helpful. Perhaps now I can stop dreading the reduce method. 😅

  • @pugazhonline
    @pugazhonline 3 роки тому +1

    I have used reduce() many times. but clearly understand now. Thanks Kyle.

  • @iooosef6006
    @iooosef6006 3 роки тому +18

    I'm looking forward for more videos about array, string, and object methods.
    Your explanations are so great.

  • @SquaredIndex
    @SquaredIndex 2 роки тому +4

    Good explanation Kyle!
    I think the second example should use undefined rather than null, then you can use strictly equals like so:
    if (groupedPeople[age] === undefined) groupedPeople[age] = []

    • @caterpilar
      @caterpilar Рік тому +1

      you can go even further using `.hasOwnProperty()` to check object key

    • @jollyjoker6340
      @jollyjoker6340 Рік тому

      null and undefined are falsy so if(groupedPeople[age]) is enough

  • @galihhad
    @galihhad Рік тому

    Thank you, I understand it much better now!

  • @munaq-jp
    @munaq-jp 3 роки тому +14

    I love the _reduce_ method. I use it for everything. I would brush my teeth with it if I could. If you ever _map-filter-map-find_ anything, do everyone a solid and just use _reduce._

  • @shvideo1
    @shvideo1 2 роки тому

    Perfect content coverage on reduce. You are amazing! Thank you for sharing.

  • @EdisonSeas
    @EdisonSeas Рік тому

    Very well explained, crystal clear. Thanks for this content!

  • @snansahmarov1524
    @snansahmarov1524 3 роки тому +2

    Thank you Kyle. You are great !

  • @Unknown-so7qv
    @Unknown-so7qv 2 роки тому

    Nice video bro, i finally have understood how to filter objects by a key with reduce thx man .

  • @ngyang5113
    @ngyang5113 3 роки тому

    u are amazing, all ur video is concise and easy to understand

  • @MrLiquitorleaveit
    @MrLiquitorleaveit 2 роки тому +2

    Incredibly well explained! Thanks so much! 🙏

  • @SiddhantaPaul80
    @SiddhantaPaul80 2 роки тому

    That's an impressive straight forward explanation!
    Really liked the analogy with forEach Loop.

  • @hayfachouchene1285
    @hayfachouchene1285 2 роки тому

    amazing explanation ! good job

  • @The1stKing
    @The1stKing 3 роки тому +1

    Haha, just what i needed. 😆 I literally just youtube-ed how to use reduce function.

  • @mattplaygamez
    @mattplaygamez 3 роки тому +2

    You deserve more subscribers

  • @simple8810
    @simple8810 3 роки тому

    reduce is like different and complex from other array methods,but you made clear that for us thanks

  • @dasten123
    @dasten123 3 роки тому +19

    I like the reduce function. But many people use it on occasions where a simple `forEach` loop would be more appropriate, and that gives the `reduce` a bad reputation, because it seems to make things unnecessarily complicated. I think you should always be aware of that whenever you are about to use it.

  • @themanshaper
    @themanshaper 2 роки тому

    Dude your explanations are so good. Thank you!

  • @re.liable
    @re.liable 2 роки тому

    I feel lucky that I was able to intuitively understand reduce for the most part. Except that second parameter. That tripped me up hard quite a bit.

  • @elkhanhamet2561
    @elkhanhamet2561 2 роки тому

    Amazing explanation. Thank you Kyle!!!🙂

  • @travel2react567
    @travel2react567 2 роки тому

    Thanks a lot for such a detailed video.

  • @princecharles-amachree7329
    @princecharles-amachree7329 3 роки тому +1

    Was legit looking for this today and my man ends up making a video on it. Coincidence? I think not

  • @Ranjithkumar-ll5rb
    @Ranjithkumar-ll5rb 2 роки тому

    you are my life saver! Thank you🙏

  • @xiampiii
    @xiampiii Рік тому

    Thank you for a great and easy to understand explanation

  • @AbhishekKumar-cd4gg
    @AbhishekKumar-cd4gg 3 місяці тому

    loved the seccond example , love from india .

  • @YannMetalhead
    @YannMetalhead 2 роки тому +1

    Simple and direct, great explanation.

  • @jollyjoker6340
    @jollyjoker6340 Рік тому

    6:57 Took me a while to make this work; you can write this as
    const toArray = (arr, elem) => arr ? [...arr, elem] : [elem]
    const grouper = (grouped, { age, name }) => ({...grouped, [age]: toArray(grouped[age], name)})
    console.log(people.reduce(grouper, {}))
    assuming you want a list of names instead of the full objects, as specced at 5:49. At least destructuring the age and name is clear enough; some of the syntax may be a bit obscure.

  • @codingwithkenny6492
    @codingwithkenny6492 3 роки тому +6

    You are awesome, Kyle! Your videos have helped me learn so much about Javascript👍

  • @SmokingSheep98
    @SmokingSheep98 3 роки тому

    I appreciate how you show multiple use cases instead of just the most simple one. Keep up the amazing videos!

  • @dr__ey
    @dr__ey 2 роки тому

    thanks so much for this explanation!!! it really helped

  • @VenkateshMogili
    @VenkateshMogili 3 роки тому

    Thank you kyle, got more clarity on Reduce method now❤😊😊👍

  • @tijanisylla1348
    @tijanisylla1348 3 роки тому

    Im always learning from Kyle ! This is an amazing !!!!

  • @dhawalparmar7117
    @dhawalparmar7117 3 роки тому +1

    Time worthy video 😍

  • @cfhall54
    @cfhall54 2 роки тому

    Much appreciated! This can definitely be a time saver

  • @meysamrezania54
    @meysamrezania54 3 роки тому

    That was pretty cool explanation

  • @bartoszsowa5140
    @bartoszsowa5140 2 роки тому

    you made it clear, thank you

  • @ramonmaximiliano3557
    @ramonmaximiliano3557 3 роки тому

    Excellent video!

  • @fatimazboujrar
    @fatimazboujrar Рік тому

    thank you so much , you've covered everything 🤩

  • @stylesg7818
    @stylesg7818 3 роки тому

    Thank you so much! It's make so much sense now.

  • @Raubritterr222
    @Raubritterr222 3 роки тому +2

    Kyle, I love your videos! You are a great teacher and a superb developer!

  • @Kae201
    @Kae201 2 роки тому

    This video was really helpful and clear. Thank you!

  • @andzisimabaso5622
    @andzisimabaso5622 3 роки тому

    This is just awesome! Finally, I get it.

  • @Zen-lz1hc
    @Zen-lz1hc 2 роки тому

    LIKE :)
    Thank you for publishing this video.
    Really clear and friendly introduction to reduce() method!

  • @pawandabi6367
    @pawandabi6367 3 роки тому

    Good explanation
    Keep posting 💥

  • @pechupechaairukkattum6986
    @pechupechaairukkattum6986 2 роки тому

    simply awesome. thanks a lot

  • @musaamuhsen
    @musaamuhsen 3 роки тому

    Dude this just saved me. Thanks!

  • @jeremey__
    @jeremey__ 2 роки тому

    thanks, good explanation!

  • @lamargtv2572
    @lamargtv2572 3 роки тому

    Diamond explanation, thanks

  • @johnwellgroup
    @johnwellgroup Рік тому

    Thank you very muh for really breaking this topi. you are the best

  • @abhishekghimire3539
    @abhishekghimire3539 3 роки тому +1

    Thanks kyle! Can't get more simple than this

  • @ts.wizard
    @ts.wizard 3 роки тому

    Thanks a ton for demonstrating the advanced features as well and the consequence of leaving the default parameter empty. That's not something everyone out here does.

  • @joelcool1027
    @joelcool1027 3 роки тому

    Thanks bro. I'm a JavaScript developer and never understood this function. You truly "simplified" it

  • @jssecrets
    @jssecrets 3 роки тому

    Thank you Kyle!

  • @chandrachurmukherjeejucse5816
    @chandrachurmukherjeejucse5816 2 роки тому

    As always a great lecture. Thanks a lot

  • @davidasteed
    @davidasteed 2 роки тому

    excellent last bit about "make sure to give reduce() a default starting accumulator value, else your code will fail if given an empty array"
    however: what is the rationale using "==" operator, vs. strict equality "===" ?: that is standard practice in nearly 100% of operational JS code I've worked on

  • @mayankchavda6839
    @mayankchavda6839 3 роки тому

    thank you so much your this vdo helps me a lot thank you so much

  • @MiSt3300
    @MiSt3300 2 роки тому

    This is a perfect explanation, thank you!

  • @shahhuzaifa2746
    @shahhuzaifa2746 3 роки тому

    Thank you so much. I saw many videos on YT of reducing the items to a single value (easy one), but NO one explained about the grouping items into categories. This literally save so much processing power. I was using two loops of approx 1000 items and approx 100 items each to categorize. But this reduce method of categorizing is so much efficient. Thanks for explaining the concept :)

  • @RonnieNissan
    @RonnieNissan 3 роки тому

    items.map((it) => it.price).reduce((a, b) => a + b, 0)

  • @mquanit
    @mquanit 3 роки тому +1

    finally, today is the day when I succesfully understood this reduce function. Thanks alot

  • @yahelsasson
    @yahelsasson Рік тому

    Awesome 🎉 thank you

  • @hathumkittitus9663
    @hathumkittitus9663 3 роки тому

    Thanks, I never set seccond parameter but from now I will alway set it 😍🥰

  • @samichpower
    @samichpower Рік тому

    Your hair is always on point 🔥

  • @wastingtime1111
    @wastingtime1111 2 роки тому

    finally! I kind of uderstand it now!

  • @yaldakarimi3772
    @yaldakarimi3772 3 роки тому

    Love your channel and how deeply you explain things, thank you