What is Factory Function in JavaScript? - JS Tutorial

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

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

  • @ColorCode-io
    @ColorCode-io  3 года назад +22

    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

    • @ColorCode-io
      @ColorCode-io  Год назад +3

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

  • @awaismohsin345
    @awaismohsin345 Год назад +46

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

  • @IanMathaiya
    @IanMathaiya Год назад +15

    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

  • @BigSmoke-r9w
    @BigSmoke-r9w 8 месяцев назад +1

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

  • @asdjafhjasbfhjasbhjf
    @asdjafhjasbfhjasbhjf 2 года назад +37

    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! :)

    • @ColorCode-io
      @ColorCode-io  2 года назад +3

      I appreciate that! Made my day.

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

      ​@@ColorCode-io this is what Apples tutorial of JS Factory function would look like.

    • @tigana
      @tigana 2 года назад

      @@asdjafhjasbfhjasbhjf This

  • @abhishekkh9983
    @abhishekkh9983 2 месяца назад

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

  • @natureislife1948
    @natureislife1948 2 года назад +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.

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

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

  • @anasaqeel2387
    @anasaqeel2387 Год назад +2

    never seen such an amazingly explanatory video before. Great job

  • @dilipkumar-dd7ud
    @dilipkumar-dd7ud 2 года назад +1

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

  • @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...

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

    I’m watching this like a t.v show. I enjoy this. 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.

  • @stoyannvelten5231
    @stoyannvelten5231 3 года назад +5

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

    • @ColorCode-io
      @ColorCode-io  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.

    • @ColorCode-io
      @ColorCode-io  3 года назад

      @@danielbedoya6517 Thanks Daniel

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

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

  • @user-ld7mt9bx9q
    @user-ld7mt9bx9q 3 года назад +12

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

    • @ColorCode-io
      @ColorCode-io  3 года назад +1

      Much appreciated!

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

      Me too! His videos are very well done!

    • @ColorCode-io
      @ColorCode-io  3 года назад +3

      @@fParad0x_ thank you

  • @richardvanhelden1420
    @richardvanhelden1420 2 года назад +5

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

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

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

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

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

    • @ColorCode-io
      @ColorCode-io  2 года назад

      Sure thing. Episode 10 is coming this week!

  • @n1mutant
    @n1mutant 2 года назад +5

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

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

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

  • @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!

  • @jollyren
    @jollyren 3 года назад +3

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

    • @ColorCode-io
      @ColorCode-io  3 года назад

      Thank you :) with time they’ll come.

  • @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 🫡.

  • @TheChiaralyn
    @TheChiaralyn 2 года назад +4

    Adorable and useful!!! Thank you!

  • @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.

    • @ColorCode-io
      @ColorCode-io  2 года назад

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

  • @renatocampos3502
    @renatocampos3502 3 года назад +6

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

    • @ColorCode-io
      @ColorCode-io  3 года назад

      Glad you liked it. Thanks for the sub.

  • @bryanDevsJS
    @bryanDevsJS Год назад +4

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

  • @mohamedazizarresse
    @mohamedazizarresse Год назад +1

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

  • @vasudev16180
    @vasudev16180 3 года назад +3

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

    • @ColorCode-io
      @ColorCode-io  3 года назад

      Thanks. Will add it to my backlog.

  • @richardradcliffe6178
    @richardradcliffe6178 2 года назад +2

    This video is awesome. Thank you so much!

  • @imranmani2036
    @imranmani2036 2 года назад +4

    Sina, YOU'RE AMAZING........ I didn't comment on RUclips 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

  • @abderraoufbenchoubane1905
    @abderraoufbenchoubane1905 2 года назад +2

    Just found this channel it's amazing great work

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

    You are freaking delightful. That is all.

  • @SiddharthRay1
    @SiddharthRay1 3 года назад +4

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

  • @corygold8206
    @corygold8206 2 года назад +4

    Extremely helpful -- thank you!

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

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

  • @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

  • @matheusdefariascavalcantis9961
    @matheusdefariascavalcantis9961 Год назад +1

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

  • @hoomtal
    @hoomtal Год назад +1

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

  • @g_pazzini
    @g_pazzini Год назад +1

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

  • @hamadaali6725
    @hamadaali6725 Год назад +1

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

  • @ross-sanderson
    @ross-sanderson 11 месяцев назад +1

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

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

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

  • @DmitryGlinskiy
    @DmitryGlinskiy 3 года назад +3

    Great video. Superb production. Helpful explanations.

  • @artikant9890
    @artikant9890 Год назад +1

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

  • @GeorgeHernandez-xh2jp
    @GeorgeHernandez-xh2jp 5 месяцев назад +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!

  • @sadafrasheed
    @sadafrasheed 5 месяцев назад

    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.

  • @bhargav772
    @bhargav772 3 года назад +3

    Subscribed after the initial factory animation. Cool video ! 😀

  • @chuabenjamin
    @chuabenjamin Год назад +1

    Learning from you is fun, Thank you

  • @PACadence43
    @PACadence43 3 года назад +3

    Amazing Editing. Thanks for the content.

  • @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 ?

  • @gshadiadi1
    @gshadiadi1 Год назад +3

    so what is the diffrent between function factory and class?

  • @borisboulogne5163
    @borisboulogne5163 Год назад +1

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

  • @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!

    • @ColorCode-io
      @ColorCode-io  2 года назад +1

      I'm considering doing a react course. Thanks!

  • @adarshtiwari7395
    @adarshtiwari7395 3 года назад +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?

    • @ColorCode-io
      @ColorCode-io  3 года назад +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 3 года назад +2

      @@ColorCode-io 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!

  • @mubarakch2233
    @mubarakch2233 2 года назад +2

    Great content. Keep uploading more❤

  • @ibarkianas3216
    @ibarkianas3216 2 года назад +2

    Thanks!

  • @chriskasatka2095
    @chriskasatka2095 2 года назад +2

    Really well done stuff!

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

    Thanks for the Tutorial!

  • @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!

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

    Great tutorial! Greetings from brazil

  • @adriananin3150
    @adriananin3150 Год назад +1

    Great explanation💯

  • @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.

    • @ColorCode-io
      @ColorCode-io  3 года назад

      ruclips.net/p/PL1PqvM2UQiMoGNTaxFMSK2cih633lpFKP

  • @gatorgrad
    @gatorgrad Год назад +1

    thanks for the tips. good stuff

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

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

  • @eumm11
    @eumm11 Год назад +1

    amazing like always!

  • @jatilyadav4000
    @jatilyadav4000 Год назад +1

    Amazing content.. Just the best

  • @elvispontes4165
    @elvispontes4165 Год назад +1

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

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

    great content Sina, thanks

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

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

  • @boooloool6039
    @boooloool6039 3 года назад +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

    • @ColorCode-io
      @ColorCode-io  3 года назад

      I touch on that in this video: ruclips.net/video/fbuyliXlDGI/видео.html

  • @andrewraj3846
    @andrewraj3846 2 года назад +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

  • @Luis-MFG
    @Luis-MFG 2 года назад +1

    Could you please make a video explaining the event loop?

  • @badbrother_2023
    @badbrother_2023 2 года назад +2

    Looking forward for you to do a video about react native

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

    GREAT TUTORIAL!

  • @DanyalTamiz-s1l
    @DanyalTamiz-s1l 2 месяца назад

    bavar nmishe to irani damet garm🔥

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

    Bro just started a new javaScript framework 😁

  • @sf-zr3oj
    @sf-zr3oj 5 месяцев назад

    You're great! Thanks by Brazil

  • @vanshmishra6039
    @vanshmishra6039 4 месяца назад

    i can't thank you enough! thanks a lot

  • @amir-am2379
    @amir-am2379 3 года назад +1

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

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

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

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

    please make all about coding javascipt

  • @MohammedFaheem-v8f
    @MohammedFaheem-v8f 12 дней назад +1

    Thanks man

  • @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?

  • @jaymartinez311
    @jaymartinez311 Год назад +1

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

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

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

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

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

  • @randymartin9040
    @randymartin9040 2 месяца назад

    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.

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

    editing is good

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

    Thank you.

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

    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?

  • @87rtlandry
    @87rtlandry 2 месяца назад

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

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

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

    • @ColorCode-io
      @ColorCode-io  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.

  • @jameslockwood8008
    @jameslockwood8008 5 месяцев назад

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

    • @ColorCode-io
      @ColorCode-io  4 месяца назад

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

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

    Thanks

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

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

  • @bharathsachin
    @bharathsachin 10 месяцев назад

    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?

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

    tell me the name of song that u use at last part of the video