What is Factory Function in JavaScript - in 1 minute

Поделиться
HTML-код
  • Опубликовано: 26 сен 2024
  • Factory Functions are an incredibly useful tool in JavaScript. It's a design pattern that's used in many languages. In this one minute coding video I will explain why they are useful, the problem they tend to solve, and a practical example. Enjoy!
    #Shorts
    =================
    Sign up for an account on www.colorcode.io and watch full courses for free.

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

  • @TheEpicNoodle
    @TheEpicNoodle 3 года назад +9

    Wow it felt so good just getting the run down of this - so many tutorial videos full of fluff but this is right to the point with a real world example! Thank you

  • @gpcgpc810
    @gpcgpc810 Месяц назад

    Thank you for the 1 minute version, it is nice.

  • @frostsmaker8966
    @frostsmaker8966 3 года назад +2

    I recommend you to make this kind of explanation, something short and concise is desirable by many people. :D

  • @JoaoVitor-pc4ps
    @JoaoVitor-pc4ps 3 года назад +2

    Your contents is helping me a lot! Thanks so much.

  • @elianrc
    @elianrc 3 года назад +2

    This is amazing! Thanks for this kind of video!

  • @nabeelahmed1721
    @nabeelahmed1721 3 года назад +1

    Wow, I could see these being used to create a blockchain

  • @jeckart3d
    @jeckart3d 3 года назад +1

    Is this something that we should do to refactor Em’s rainbow?! Also, happy to see a new 1-minute vid!

    • @ColorCodeio
      @ColorCodeio  3 года назад +1

      Thanks, man :) There's going to be room for refactoring for sure, but I don't know if this particular pattern applies unless she's writing JavaScript.

    • @jeckart3d
      @jeckart3d 3 года назад +1

      @@ColorCodeio ahhhh, alright. I had thought what she was doing was based on JavaScript but in a “kid-friendly” wrapper.

    • @ColorCodeio
      @ColorCodeio  3 года назад

      @@jeckart3d Yeah I remember there was an option to write actual JS or use the visualizer tool to make it easier. I wonder if there's a full JS engine behind that thing. Probably.🤷🏻‍♂️

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

    mind blown.

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

    Quality.

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

    Nicely explained. Is that how react's jsx. Elements are made?

  • @mech-r4v
    @mech-r4v День назад

    You can just use class

  • @killvapkillvaps3719
    @killvapkillvaps3719 3 года назад +1

    I 'm still confusing, why people use constructor functions if exists factory. Factory functions more flexible: it's not reqired 'this' and 'new' keywords, haven't privacy issues and don't have a problems with losing context with 'this' when we have a nested functions. Can you explain in which cases we should use 'constructor' ?

    • @ColorCodeio
      @ColorCodeio  3 года назад

      Yep, explaining that in episode 5.

    • @killvapkillvaps3719
      @killvapkillvaps3719 3 года назад +1

      @@ColorCodeio thanks, will waiting for new episode)

  • @yatin1370
    @yatin1370 9 месяцев назад +1

    This was hugely helpful, understood the concept better. Thanks.

  • @1Dshan
    @1Dshan Год назад

    I recently implemented a strategy pattern, for rendering cards on a page. The rendering logic was a little bit different for each card. Then I used a factory to instantiate the different strategies and pass the correct strategy too the view, worked really nicely