filmov
tv
Factory Functions in JavaScript
![preview_player](https://i.ytimg.com/vi/rij0Li7etvM/maxresdefault.jpg)
Показать описание
Learn how to use JavaScript factory functions in this episode of Decoded. We will learn this design pattern and see how factory functions, when coupled with other concepts such as closures can create private variables. They also remove the need to use things such as 'this' or 'new' in JS.
Factory functions in JavaScript are similar to constructor functions / class functions, but instead do not require use of the 'this' keyword for inner values or use of the 'new' keyword when instantiating new objects. Factory functions can contain inner values, methods and so on, just like regular functions. The difference is that factory functions always return an object, which will contain any values, methods etc that we would like to expose.
As you can tell, I recorded this 'off the cuff' and ended up forgetting to talk about a couple of key points in particular (and maybe didn't explain certain concepts as well as I would have liked to). If this video gets popular I may look to rerecord it in the future. There's also a big chunk of information related to closures that I would like to cover but opted to leave that for a separate video (as the topic of closure is pretty big in its own right).
Factory functions in JavaScript are similar to constructor functions / class functions, but instead do not require use of the 'this' keyword for inner values or use of the 'new' keyword when instantiating new objects. Factory functions can contain inner values, methods and so on, just like regular functions. The difference is that factory functions always return an object, which will contain any values, methods etc that we would like to expose.
As you can tell, I recorded this 'off the cuff' and ended up forgetting to talk about a couple of key points in particular (and maybe didn't explain certain concepts as well as I would have liked to). If this video gets popular I may look to rerecord it in the future. There's also a big chunk of information related to closures that I would like to cover but opted to leave that for a separate video (as the topic of closure is pretty big in its own right).
Комментарии