Implementing JavaScript creational patterns


show more Implementing JavaScript creational patterns provides you with in-depth training on Developer. Taught by Joseph LeBlanc as part of the Node.js Essential Training (2013) show less
please wait ...

Implementing JavaScript creational patterns

While it's possible to get around module caching by using function scopes, it isn't the most flexible solution. In this video, we'll rework a module to generate objects. Let's start with the code from the previous video. Go to exercise files and chapter four, video three, and then copy the Start folder to the desktop. Now open the Start folder in a text editor. I'm going to go to Flight and index.js. In here, we have our current module, and it's exporting one function, and that function is creating a scope where we're holding all the variables.

What I'd like to do is create another function that will serve as the base for new objects. Let's do that now. Make some space at the top and then type var Flight, with a capital F, equals function. Don't define any arguments for this function, and clean out the body. Notice that we're using a capital F for flight. This is just a reminder that we're using this as the base for new objects. Now let's start adaptin...

Implementing JavaScript creational patterns
Video duration: 5m 8s 3h 17m Intermediate

Viewers:

Implementing JavaScript creational patterns provides you with in-depth training on Developer. Taught by Joseph LeBlanc as part of the Node.js Essential Training (2013)

Subject:
Developer
Software:
JavaScript Node.js
Author:
please wait ...