In this video Emmanuel Henri explains the constructor pattern with an example.
- [Instructor] Similar to the class prototype pattern,…the constructor pattern is one step further…from the class pattern, where we leverage a class created…to initiate a new extended class from it.…Let me demonstrate.…So let's go back to the index.js,…and create a brand new class.…So, Return after line 7, and then create a new class…that we'll call Suv, and then we extend…with an s by the way, the Car class.…
So what we're doing here is leveraging what we've built…inside of that class here to create a new one.…So the way we do this, again, we use the constructor,…and we make sure we pass the values of the initial class.…And then we do super to initialize the values…or the class constructor here, in Car, with our Suv,…and then pass the value doors, engine, and then color.…
And then, if you want to add its own values for Suv,…the ones that are not going to show in the class Car,…but items and variables that you want just for the Suv,…you could do this.wheels, and then you can…even initialize with default value like this.…
- What's a pattern?
- What's the role of callbacks?
- Creational patterns, including Singleton and Factory
- Structural patterns, including model-view-controller
- Behavioral patterns, including Memento and Mediator
Skill Level Intermediate
2. Creational Patterns
3. Structural Patterns
4. Behavioral Patterns
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.