What is Factory Function in JavaScript? - JS Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ต.ค. 2024

ความคิดเห็น • 226

  • @ColorCodeio
    @ColorCodeio  3 ปีที่แล้ว +21

    What is Factory Function in JavaScript? This is episode 3 in a 10 part series I'm calling 10 Things JS Developers Should Know, but Probably Don't. 💻🤷🏻‍♂️💛

    • @Justnadeem
      @Justnadeem ปีที่แล้ว

      can you tell me what IDE YOU USE

    • @Justnadeem
      @Justnadeem ปีที่แล้ว

      I NEED HELP CAUSE EVERY TIME FOR PROTO AND INHERITANCE I HAVE TO DEVTOOL CONSOLE

    • @ColorCodeio
      @ColorCodeio  ปีที่แล้ว +2

      @@Justnadeem it’s called RunJS. See here: runjs.app?via=colorcode

  • @awaismohsin345
    @awaismohsin345 ปีที่แล้ว +44

    I request the government to give this man a medal at the government level for his high performance and excellent work.(A lot respect)

    • @ColorCodeio
      @ColorCodeio  ปีที่แล้ว +1

      🙏🎖️ Thanks dude.

  • @IanMathaiya
    @IanMathaiya ปีที่แล้ว +12

    I discovered your channel two days ago and I'm still stunned by how good your videos are.
    The editing is super professional (really appreciating the background music),
    Explanations are so easy even a 5 year old can understand
    And you're hella funny.
    Thanks 10X

  • @asdjafhjasbfhjasbhjf
    @asdjafhjasbfhjasbhjf 2 ปีที่แล้ว +36

    Dude this is EXTREMLY good content.
    Good graphics, good camera, funny and slow pase for my beginner brain.
    This channel will blow up.
    Thank you! :)

    • @ColorCodeio
      @ColorCodeio  2 ปีที่แล้ว +3

      I appreciate that! Made my day.

    • @asdjafhjasbfhjasbhjf
      @asdjafhjasbfhjasbhjf 2 ปีที่แล้ว +1

      ​@@ColorCodeio this is what Apples tutorial of JS Factory function would look like.

    • @tigana
      @tigana 2 ปีที่แล้ว

      @@asdjafhjasbfhjasbhjf This

  • @saketsingh4345
    @saketsingh4345 ปีที่แล้ว +3

    This man is absolutely mind blowing with his work, the video quality, the editing everything...and specially the explanation of the topic totally on point....
    Channel definitely blowing up soon...

  • @user-ld7mt9bx9q
    @user-ld7mt9bx9q 3 ปีที่แล้ว +12

    Excellent production quality. I am looking forward to seeing your channel grow.

    • @ColorCodeio
      @ColorCodeio  3 ปีที่แล้ว +1

      Much appreciated!

    • @fParad0x_
      @fParad0x_ 3 ปีที่แล้ว +2

      Me too! His videos are very well done!

    • @ColorCodeio
      @ColorCodeio  3 ปีที่แล้ว +3

      @@fParad0x_ thank you

  • @PatrikRasch
    @PatrikRasch 2 ปีที่แล้ว +3

    Yeah the quality kept going throughout. Incredible job. Thank you so much.

    • @ColorCodeio
      @ColorCodeio  2 ปีที่แล้ว

      Glad you enjoyed it!

  • @natureislife1948
    @natureislife1948 ปีที่แล้ว +8

    Just found your channel after watching a tonne of videos on JS Factory, you made things so much easier & simpler to understand, Hats off to you brother, genuinely loved your method of teaching & that soothing background soundtrack you had me absolutely focused from start to finish.

    • @ColorCodeio
      @ColorCodeio  ปีที่แล้ว

      Thank you! Glad it's helpful.

  • @stoyannvelten5231
    @stoyannvelten5231 3 ปีที่แล้ว +5

    the quality production of this video is probably the best i ever seen on you tube ! ;) thanks

    • @ColorCodeio
      @ColorCodeio  3 ปีที่แล้ว +1

      Thank you :) I put a lot of work into these so it's nice to hear.

    • @danielbedoya6517
      @danielbedoya6517 3 ปีที่แล้ว +1

      I was thinking exactly the same. Great job.

    • @ColorCodeio
      @ColorCodeio  3 ปีที่แล้ว

      @@danielbedoya6517 Thanks Daniel

  • @bryanDevsJS
    @bryanDevsJS ปีที่แล้ว +4

    the editing skills and tutorial is superb new subscriber here.. love the camera transition from full to little circle,

  • @abhishekkh9983
    @abhishekkh9983 หลายเดือนก่อน

    I am not even bored to watch it 5 times! Thank you for this videos.

  • @unespc
    @unespc 2 ปีที่แล้ว +3

    Amazing description Sina, Hope to see more video of yours dadash!

    • @ColorCodeio
      @ColorCodeio  2 ปีที่แล้ว

      Sure thing. Episode 10 is coming this week!

  • @anasaqeel2387
    @anasaqeel2387 ปีที่แล้ว +2

    never seen such an amazingly explanatory video before. Great job

  • @jollyren
    @jollyren 2 ปีที่แล้ว +3

    Can't believe you don't have more views! I've learned more, more quickly and intuitively, than any other tuts.

    • @ColorCodeio
      @ColorCodeio  2 ปีที่แล้ว

      Thank you :) with time they’ll come.

  • @renatocampos3502
    @renatocampos3502 3 ปีที่แล้ว +6

    What a video bro, what a quality production!!! One more subscriber! Keep up the good work! Thank you very much!

    • @ColorCodeio
      @ColorCodeio  3 ปีที่แล้ว

      Glad you liked it. Thanks for the sub.

  • @fariskanbur5428
    @fariskanbur5428 2 ปีที่แล้ว +3

    Amazing description Sina, I am looking forward to seeing your new series about Js and React js.

  • @GeorgeHernandez-xh2jp
    @GeorgeHernandez-xh2jp 4 หลายเดือนก่อน +1

    Awesome video! Learning about factory functions in my bootcamp right now and this really helped me better understand! The effects and music are high quality, and you break it down so well!🤓 I also really love when code content creators don't edit out their mistakes. It really helps to see possible bugs and fixes! And also encouraging to see people at this level are still human too 😅 Subscribed! Cheers!

    • @ColorCodeio
      @ColorCodeio  4 หลายเดือนก่อน

      Definitely 🙏

  • @richardvanhelden1420
    @richardvanhelden1420 ปีที่แล้ว +5

    You have a very pleasant and clear way of explaining things. Super good content thx!!

  • @BigSmoke-r9w
    @BigSmoke-r9w 7 หลายเดือนก่อน +1

    Holy shit, its so simple! I love it! Thank you!

  • @markivkovic7235
    @markivkovic7235 ปีที่แล้ว +2

    Hey Sina, Compelled to comment as I've been devouring these JS videos in a random order alongside a bootcamp i'm on. Almost anytime i get snagged up on something I'm back searching for a video on the topic. You seem a very natural teacher and obviously deeply understand your subject, unlike many other tutorials where it's just a telling of 'info', your videos are a true sharing of knowledge. Thanks sir.

    • @ColorCodeio
      @ColorCodeio  ปีที่แล้ว

      Great to hear. Thank you!

  • @dilipkumar-dd7ud
    @dilipkumar-dd7ud ปีที่แล้ว +1

    Thanks for covering factory function, Extremely helpful -- Thank you!

  • @artikant9890
    @artikant9890 ปีที่แล้ว +1

    just found your channel...so proud to learn first 3 videos...(falling for let's shrink whoop ) LOVE FROM INDIA💖

    • @ColorCodeio
      @ColorCodeio  ปีที่แล้ว

      Shhhhhhrink!

    • @artikant9890
      @artikant9890 ปีที่แล้ว

      @@ColorCodeio you read !! Thanks man😭❤️

  • @bhargav772
    @bhargav772 3 ปีที่แล้ว +3

    Subscribed after the initial factory animation. Cool video ! 😀

  • @vasudev16180
    @vasudev16180 2 ปีที่แล้ว +3

    Excellent video as always bro! I request you to please make a video series on Design Patterns.

    • @ColorCodeio
      @ColorCodeio  2 ปีที่แล้ว

      Thanks. Will add it to my backlog.

  • @ross-sanderson
    @ross-sanderson 10 หลายเดือนก่อน +1

    Thanks for the tutorial. Your way of teaching is simple, easy to understand, and engaging. You've earned a sub. Keep it up!

    • @ColorCodeio
      @ColorCodeio  10 หลายเดือนก่อน

      Thank you

  • @iamwaiyanminhtet
    @iamwaiyanminhtet ปีที่แล้ว +2

    You don't know how much I appreciate for this series. Your contents are really helpful for beginners like me and at the same time also entertaining. Thanks brother. Salute 🫡.

    • @ColorCodeio
      @ColorCodeio  ปีที่แล้ว

      Very glad to hear it. Thank you.

  • @Hero1Love2
    @Hero1Love2 2 ปีที่แล้ว +1

    I’m watching this like a t.v show. I enjoy this. Thank you 🙏🏾

  • @adarshtiwari7395
    @adarshtiwari7395 2 ปีที่แล้ว +8

    I have seen many tutorials but this one was the most definitive of them all. Great work brother! Would you suggest learning only classes or factory functions or is it necessary to learn both? For simplicity purposes could we just get familiar with one?

    • @ColorCodeio
      @ColorCodeio  2 ปีที่แล้ว +3

      Modern JavaScript patterns are moving more toward functional programming and away from Classes. With that said I think any JS developer should have an understanding of both. They're not that difficult to learn.

    • @adarshtiwari7395
      @adarshtiwari7395 2 ปีที่แล้ว +2

      @@ColorCodeio Alright.... Right now I'm trying to code a factory function that returns an object which is basically a button with a dropdown list when hovered over. Let's see how it goes!

  • @abderraoufbenchoubane1905
    @abderraoufbenchoubane1905 2 ปีที่แล้ว +2

    Just found this channel it's amazing great work

  • @LizyAd
    @LizyAd 7 หลายเดือนก่อน +1

    I am so glad I came across your channel. You make learning Javascript fun and you're super funny lol. Thanks a lot!

    • @ColorCodeio
      @ColorCodeio  7 หลายเดือนก่อน

      Happy to hear that!

  • @n1mutant
    @n1mutant 2 ปีที่แล้ว +4

    you got a sub!! don't stop my dude don't stop!!! great content

  • @SiddharthRay1
    @SiddharthRay1 3 ปีที่แล้ว +4

    Hey, Thanks for covering factory function, it is very very useful in many many scenarios.

  • @pakcommanderh8280
    @pakcommanderh8280 ปีที่แล้ว

    1st time i didn't get bore while learning js ( best teach ever )

  • @hoomtal
    @hoomtal ปีที่แล้ว +1

    The Education needs you man! Keep On ...👌🏽خیلی کارت درسته

  • @mohamedazizarresse
    @mohamedazizarresse ปีที่แล้ว +1

    this is my first video here and I can firmly say that this guy is worth a subscribe

  • @DmitryGlinskiy
    @DmitryGlinskiy 3 ปีที่แล้ว +3

    Great video. Superb production. Helpful explanations.

  • @PatrikRasch
    @PatrikRasch 2 ปีที่แล้ว +2

    I'm only 3 minutes into this video atm but MAN this video is well made.

  • @JJ-ot3ps
    @JJ-ot3ps 2 ปีที่แล้ว +2

    love the way you teach and explain the logic step by step!!!!! You should also do react series too!

    • @ColorCodeio
      @ColorCodeio  2 ปีที่แล้ว +1

      I'm considering doing a react course. Thanks!

  • @bmehder
    @bmehder 2 ปีที่แล้ว +1

    I am pretty sure that a 30 year old Eugene Levy just taught me about Factory Functions, and I appreciate that.

    • @ColorCodeio
      @ColorCodeio  2 ปีที่แล้ว

      Haha more like 36 but I'll take it. And thanks for the sub.

  • @hamadaali6725
    @hamadaali6725 ปีที่แล้ว +1

    your video is great, i watched alot of tuts and i didn't get it, but now i understand everything

  • @Amy_A.
    @Amy_A. 2 ปีที่แล้ว +1

    I use factory functions for organizing an API I maintain. There's about a dozen "sections" of the API, so I split those sections into their own files and load them into a static object at runtime. It's much easier to maintain than a single file with hundreds of functions in it.

  • @lewitness1759
    @lewitness1759 2 ปีที่แล้ว +2

    Awesome explanation!

  • @PACadence43
    @PACadence43 3 ปีที่แล้ว +3

    Amazing Editing. Thanks for the content.

  • @matheusdefariascavalcantis9961
    @matheusdefariascavalcantis9961 ปีที่แล้ว +1

    Awesome video!!
    Very good teaching, subject very well explained!

  • @corygold8206
    @corygold8206 2 ปีที่แล้ว +4

    Extremely helpful -- thank you!

  • @TheChiaralyn
    @TheChiaralyn 2 ปีที่แล้ว +3

    Adorable and useful!!! Thank you!

  • @mickeyp1291
    @mickeyp1291 ปีที่แล้ว +1

    Great stuff. Liking your videos. I would caution you against writing static functions that assume a context. In this case you assume thw document object which you are using by interracting with you outter scope. This means your function cannot add elements to other scopes. What you should do is introduce an element object and act on it instead of document and document body. The dom heirarchy should be the context in this case

  • @borisboulogne5163
    @borisboulogne5163 ปีที่แล้ว +1

    Thanks man, honestly this has been the best « under the hood » series I have found so far, keep going 🔥

  • @g_pazzini
    @g_pazzini 11 หลายเดือนก่อน +1

    Thanks for sharing your knowledge with fun and joy❤❤❤

  • @richardradcliffe6178
    @richardradcliffe6178 2 ปีที่แล้ว +2

    This video is awesome. Thank you so much!

  • @alih1210
    @alih1210 3 ปีที่แล้ว +2

    for the first minute of this video i knew that i'm gonna subscribe and like this video

    • @ColorCodeio
      @ColorCodeio  3 ปีที่แล้ว

      That's awesome! Thank you :)

  • @chuabenjamin
    @chuabenjamin ปีที่แล้ว +1

    Learning from you is fun, Thank you

  • @imranmani2036
    @imranmani2036 ปีที่แล้ว +4

    Sina, YOU'RE AMAZING........ I didn't comment on TH-cam videos, but YOUR CONTENT forced me to comment, and APPRECIATE YOUR EFFORTS.
    I REALLY LOVE your explanation and GRAPHICS.
    LOOKING FORWARD TO MUCH MORE FROM YOU :)
    THANKS

    • @ColorCodeio
      @ColorCodeio  ปีที่แล้ว +1

      I appreciate that 🙏

  • @mdsalim-yo6dq
    @mdsalim-yo6dq 3 ปีที่แล้ว +1

    sir, please create a playlist for javascript. It will help every student who is learning javascript. your teaching method is very easy and gorgeous. thank you.

    • @ColorCodeio
      @ColorCodeio  3 ปีที่แล้ว

      th-cam.com/play/PL1PqvM2UQiMoGNTaxFMSK2cih633lpFKP.html

  • @sadafrasheed
    @sadafrasheed 3 หลายเดือนก่อน

    Just want to add a thing. I belong to the old school where we were taught to keep an eye on your code's memory requirements. Duplicating code means more RAM is needed. This may not have a major effect on the front end, but on the back end, more RAM for the script can be an issue.

  • @MariaMartinkous
    @MariaMartinkous ปีที่แล้ว

    Hi! I absolutely love your videos, they are extremely helpful in understanding such complex topic. Only one thing - the background music is either distracting (I have ADHD, so it already takes a huge effort to concentrate as it is), or way too soothing (literally makes me super sleepy even after a full night's sleep). Other than the background noise, I am very thankful that you created this series!

  • @yasminelmahdi2003
    @yasminelmahdi2003 ปีที่แล้ว +1

    Absolutely loved the way you explain this type of functions, but I don't get why factory functions shouldn't be creating elements inside the DOM ?

  • @adriananin3150
    @adriananin3150 ปีที่แล้ว +1

    Great explanation💯

  • @boooloool6039
    @boooloool6039 2 ปีที่แล้ว +2

    love your videos man! soo, soo awesome ! do you think, you can briefly describe when to use factory functions and when class?
    its really confusing me, because to me, factory functions seem to be much easier to use

    • @ColorCodeio
      @ColorCodeio  2 ปีที่แล้ว

      I touch on that in this video: th-cam.com/video/fbuyliXlDGI/w-d-xo.html

  • @mubarakch2233
    @mubarakch2233 ปีที่แล้ว +2

    Great content. Keep uploading more❤

  • @andrewraj3846
    @andrewraj3846 ปีที่แล้ว +1

    Bro Awesome Video. Enlightened.
    1 question - What's the difference between Class and Factory function, other than the OOPS concepts? I mean like memory usage, processing speed, etc

  • @jonathancollins1182
    @jonathancollins1182 2 ปีที่แล้ว +1

    You are freaking delightful. That is all.

  • @chriskasatka2095
    @chriskasatka2095 2 ปีที่แล้ว +2

    Really well done stuff!

  • @ibarkianas3216
    @ibarkianas3216 2 ปีที่แล้ว +2

    Thanks!

  • @gatorgrad
    @gatorgrad 11 หลายเดือนก่อน +1

    thanks for the tips. good stuff

  • @elvispontes4165
    @elvispontes4165 ปีที่แล้ว +1

    your videos are awesome my friend... thanks for sharing!!

    • @ColorCodeio
      @ColorCodeio  9 หลายเดือนก่อน

      👍👍

  • @randymartin9040
    @randymartin9040 28 วันที่ผ่านมา

    Love your videos. At around 9:00 you state that now using the factory function the Object's name can't be changed. It wasn't demonstrated there so it's a bit confusing.

  • @by2313
    @by2313 3 ปีที่แล้ว +1

    Thanks for the Tutorial!

  • @jatilyadav4000
    @jatilyadav4000 ปีที่แล้ว +1

    Amazing content.. Just the best

  • @JoaoVitor-pc4ps
    @JoaoVitor-pc4ps 3 ปีที่แล้ว +1

    Great tutorial! Greetings from brazil

  • @eumm11
    @eumm11 ปีที่แล้ว +1

    amazing like always!

  • @badbrother_2023
    @badbrother_2023 2 ปีที่แล้ว +2

    Looking forward for you to do a video about react native

  • @projectlinz8191
    @projectlinz8191 ปีที่แล้ว

    great content Sina, thanks

  • @gshadiadi1
    @gshadiadi1 ปีที่แล้ว +3

    so what is the diffrent between function factory and class?

  • @praveensb4880
    @praveensb4880 3 ปีที่แล้ว +1

    Awesome video brooo completely loved this video.......

  • @Luis-MFG
    @Luis-MFG 2 ปีที่แล้ว +1

    Could you please make a video explaining the event loop?

  • @chrisgood2go
    @chrisgood2go 3 ปีที่แล้ว +1

    bro i liked the video at the drop just for that.

  • @myko_chxn
    @myko_chxn 3 ปีที่แล้ว +1

    Great video, hoping for more great vids in the future :)

    • @ColorCodeio
      @ColorCodeio  3 ปีที่แล้ว

      Yep! More coming end of July

  • @DanyalTamiz-s1l
    @DanyalTamiz-s1l 22 วันที่ผ่านมา

    bavar nmishe to irani damet garm🔥

  • @TejveerBath
    @TejveerBath ปีที่แล้ว

    I’m amazing content !! I just want to know what ide are you coding in thanks !

  • @dopamine9176
    @dopamine9176 2 ปีที่แล้ว +1

    please make all about coding javascipt

  • @amir-am2379
    @amir-am2379 3 ปีที่แล้ว +1

    فوق العاده ای تو پسر

    • @ColorCodeio
      @ColorCodeio  3 ปีที่แล้ว

      👊🏼👊🏼♥️

  • @87rtlandry
    @87rtlandry หลายเดือนก่อน

    Can you do another vid highlighting using private variables in factory functions?

  • @bharathsachin
    @bharathsachin 9 หลายเดือนก่อน

    Buddy, you have made a very good presentation. Even though the factory function can return h1, I think we can still modify the innertext without using the setText metod by just accessing the property by h1.el.innertext, is not true? For eg, below code snippet,
    function personFactory(name, age) {
    const person = {
    name: name,
    age: age
    }
    return {
    person,
    setName(name) {
    person.name = name;
    },
    setage(age) {
    person.age = age;
    }
    }
    }
    const anonymous = personFactory('anonymous', 25);
    console.log(anonymous.person);
    anonymous.person.name = 'anonymous anonymous';
    console.log(anonymous.person);
    How do you tackle such situtations?

  • @bibek8284
    @bibek8284 3 ปีที่แล้ว +2

    Can you also give a real world example which can be applicable in backend??

    • @ColorCodeio
      @ColorCodeio  3 ปีที่แล้ว

      These are all design patterns agnostic to frontend or backend. It’s just a way of organizing code so you can def use most of the stuff I teach on backend. The only thing you can’t use it the DOM API which I sometimes use to provide examples.

  • @Talel_kraiem
    @Talel_kraiem ปีที่แล้ว

    Bro just started a new javaScript framework 😁

  • @jaymartinez311
    @jaymartinez311 ปีที่แล้ว +1

    is that the browser console your using??? or an extension for the browser?

    • @ColorCodeio
      @ColorCodeio  ปีที่แล้ว

      Chrome DevTools console

  • @sf-zr3oj
    @sf-zr3oj 3 หลายเดือนก่อน

    You're great! Thanks by Brazil

    • @ColorCodeio
      @ColorCodeio  2 หลายเดือนก่อน

      Thank you too!

  • @jojojawjaw
    @jojojawjaw 3 ปีที่แล้ว

    GREAT TUTORIAL!

  • @bakshirocks
    @bakshirocks 2 ปีที่แล้ว +1

    Can you explain how the prototype chain be created by using thhe factory functions like wr can by using the constructor functions?

  • @xenocampanoli815
    @xenocampanoli815 ปีที่แล้ว

    Thank you.

  • @vanshmishra6039
    @vanshmishra6039 2 หลายเดือนก่อน

    i can't thank you enough! thanks a lot

    • @ColorCodeio
      @ColorCodeio  2 หลายเดือนก่อน +1

      Glad it helped!

  • @startwithme4
    @startwithme4 3 ปีที่แล้ว +1

    editing is good

  • @athif2200
    @athif2200 2 ปีที่แล้ว +1

    Thanks

  • @dmp9356
    @dmp9356 3 ปีที่แล้ว +2

    How do you clear the console of all previously declared variables / classes / functions?

  • @jameslockwood8008
    @jameslockwood8008 3 หลายเดือนก่อน

    1:06 Not sure what *Craig* did, but that call-out felt personal 😂

    • @ColorCodeio
      @ColorCodeio  2 หลายเดือนก่อน

      It's a personal hang up of mine. Not fair to Craig.

  • @randymartin9040
    @randymartin9040 9 วันที่ผ่านมา

    Does this only work because of how closures work? me.name isn't actually a property so it can't be returned, because at time of object instantiation the closure referenced the passed in name and it (still don't know how it tracks this in memory) knows / has knowledge of what name it was given, but has no actual name property?

  • @Dheerajvasireddy
    @Dheerajvasireddy 2 ปีที่แล้ว +1

    hi ... is this considered learning react also ? (is this useful for react js too?).....

  • @vamshikrishnareddy76
    @vamshikrishnareddy76 2 ปีที่แล้ว +1

    thank you!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • @Uri.Sab.
    @Uri.Sab. ปีที่แล้ว +1

    I love the 10:40 min jajaja