Factory Functions in JavaScript

Publicado el: 06 septiembre 2020
en el canal de: In Plain English
2,804
91

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).

GitHub repo: https://github.com/sunil-sandhu/youtu...


En esta página del sitio puede ver el video en línea Factory Functions in JavaScript de Duración hora minuto segunda en buena calidad , que subió el usuario In Plain English 06 septiembre 2020, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 2,804 veces y le gustó 91 a los espectadores. Disfruta viendo!