How to Use the New JS Object GroupBy Method

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

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

  • @barungh
    @barungh 8 месяцев назад +4

    Congratulations on 100K subscribers,
    and thanks a lot for sharing your knowledge and expertise

  • @Mark-ms8gk
    @Mark-ms8gk 8 месяцев назад

    100k! It was a long journey but very well deserved. Congratulations!

  • @thejarxtv
    @thejarxtv 8 месяцев назад +1

    I always enjoy your videos, cheers on those 100K!

  • @cristian702
    @cristian702 8 месяцев назад

    Welcome back! Just noticed your new videos. Yes!

  • @codetechpro
    @codetechpro 8 месяцев назад

    I always enjoy your videos, something new I learned today, thanks Steve

  • @shahinza
    @shahinza 8 месяцев назад

    Thank you professor for the great video

  • @muhammadhossam8557
    @muhammadhossam8557 8 месяцев назад +1

    very helpful details
    thanks for your great videos

  • @zbjz
    @zbjz 7 месяцев назад

    GroupBy Method starts at 5:50

  • @LucianoClassicalGuitar
    @LucianoClassicalGuitar 8 месяцев назад

    Finally Steve is back!

  • @binodsharma112
    @binodsharma112 8 месяцев назад

    Great video, Thank you

  • @sachin.tandon
    @sachin.tandon 8 месяцев назад

    Is there a way of using this function to do a 2-level nested grouped Map/Object, if one were to provide a pair of keys, e.g. { key, sub-key }

  • @deepakvishwakarma2043
    @deepakvishwakarma2043 8 месяцев назад

    great ! can we also sort this based on no. of items in series instead of random order (length of keys : []) ?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  8 месяцев назад

      You can group by length of keys yes. There is no sorting in an object. The order in an object is based on the order that the keys were added.

  • @user_8911
    @user_8911 8 месяцев назад

    It would be nice to add performance comparison section to the video.

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  8 месяцев назад

      In terms of real world usage, unless you have multiple thousands of objects in your array it is not going to matter which approach you use. This method is for developer convenience.

  • @SureddiBhargav
    @SureddiBhargav 8 месяцев назад

    Hello Sir, can you please make videos on node js background processes, how the cores come into play?

  • @xxapoloxx
    @xxapoloxx 8 месяцев назад

    why is this in object and not in array?.

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  8 месяцев назад

      It returns an Object not an array. The Map object also has a groupBy method if the keys are not strings or symbols.

    • @xxapoloxx
      @xxapoloxx 8 месяцев назад

      @@SteveGriffith-Prof3ssorSt3v3 so does reduce, this clearly a collection processing functionality, this belongs in array, this bad design.

  • @fellastout
    @fellastout 8 месяцев назад

    Lipstick on a pig (map method)? But it looks useful, thanks Steve.

  • @aleksandarpopovic3615
    @aleksandarpopovic3615 8 месяцев назад

    behind the scene
    movies.reduce((groupBY, item) => {
    if(!groupBY[item.series]) groupBY[item.series] = [];
    groupBY[item.series].push(item)
    return groupBY
    }, {})
    I don't understand the purpose of adding things without some benefit...
    nothing less code is written...
    who does not understand reduce, will not understand this either

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  8 месяцев назад +3

      If all you are doing is what you did in that reduce statement, then with the new groupBy you could reduce all the code into this one line:
      Object.groupBy(movies, ({series})=>series);
      which I would argue is much easier to read and understand than the reduce method. I've been teaching Array.reduce to students for years and they frequently struggle with the syntax.
      The more complex the situation, the more options that you are adding, the longer the code becomes, regardless of which option you pick.

    • @lllllllllIIIIIIIIIIl
      @lllllllllIIIIIIIIIIl 8 месяцев назад

      You don't see the benefit of writing less code vs. more code? Wow. Where do you work, so we can all know not to apply?