JavaScript Question: What is a Factory Function?

preview_player
Показать описание
What is a factory function? In this tutorial we are going to talk about what they are and when you might want to use them. We will also address the value of closure with factory functions.

Would you like to help keep this channel going?

Tutorials referred to in this video:

For more resources on JavaScript:

#javascript #AllThingsJavaScriptLLC
Рекомендации по теме
Комментарии
Автор

Nothing like that first javascript lesson of the day with a cup of coffee :)

russelldriver
Автор

The other day I was recommending your channel and courses on Twitter or Instagram (can't remember which), and it went something like this: "Do you know the renowned physicist Prof. Richard Feynman, A.K.A The Great Explainer? Well, Prof. Hancock is basically the Richard Feynman of JavaScript. Go watch his tutorials."

MauriceLacerda
Автор

You are a great teacher, i do really enjoy every video. Thanks for every one of them.!!!

victorlazo
Автор

In your example, you could also use a closure inside the Greeting2 by using the 'greet' parameter instead of 'this.greeting'. Otherwise great introduction, keep up the good work.

veronnahkur
Автор

Really nice comparisons, thanks. Although I believe it to be deprecated and discouraged, a prototype can be easily assigned in a factory function by including a __proto__ property, set to the name of the prototype object, in the returned object. I've always found this to be convenient although wish there were a modern equivalent that could also be written directly into the return object (I haven't found a way to implement the setPrototypeOf object method from within the object sensibly and have to apply it to each instance of the object after it's been returned).

batchrocketproject
Автор

Proud to give first like and comment for this video 🎥 thank u so much 🙏🏽

arunkaiser
Автор

You are the best teacher
Please Make videos on 2d arrays problems and Jquery videos...

maheshgoud
Автор

Can I request a NodeJs video about building a custom REPL and the context objects please 😄 Thank for your amazing work...

Luxcium
Автор

why does it not return automatically, like when you first initialize ffun = factoryFun(5)? my logic coming from other PLs is that right there after that line ffun would equal 500.

christiantraylor