Factory Functions in JavaScript

Veröffentlicht am: 06 September 2020
auf dem Kanal: 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...


Auf dieser Seite können Sie das Online-Video Factory Functions in JavaScript mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer In Plain English 06 September 2020 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 2,804 Mal angesehen und es wurde von 91 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!