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.
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
Glad it helped!
Thank you for the 1 minute version, it is nice.
I recommend you to make this kind of explanation, something short and concise is desirable by many people. :D
Thanks!
Your contents is helping me a lot! Thanks so much.
Happy to hear that!
This is amazing! Thanks for this kind of video!
Thank you
Wow, I could see these being used to create a blockchain
Is this something that we should do to refactor Em’s rainbow?! Also, happy to see a new 1-minute vid!
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.
@@ColorCodeio ahhhh, alright. I had thought what she was doing was based on JavaScript but in a “kid-friendly” wrapper.
@@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.🤷🏻♂️
mind blown.
🤯
Quality.
Nicely explained. Is that how react's jsx. Elements are made?
You can just use class
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' ?
Yep, explaining that in episode 5.
@@ColorCodeio thanks, will waiting for new episode)
This was hugely helpful, understood the concept better. Thanks.
Great!
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