From the course: JavaScript Essential Training

Unlock this course with a free trial

Join today to access over 22,400 courses taught by industry experts.

Classes: Object blueprints

Classes: Object blueprints

- Now we get to the really interesting part of objects. Creating objects blueprints or templates using classes. Side notes, classes are relatively new introduction to JavaScript but they've been around in other programming languages for a long time. So if you have previous experience with classes in other languages, this will all look very familiar to you. Okay, say you have a series of objects and you want to make quick work of setting them up. Verbosely declaring each object the way we've done so far would produce a lot of code and a lot of repetition since each property and method would have to be defined for each new object. A better solution is to build some sort of template. And for that, we have classes. Classes work as templates for an object type. And anytime we create a new object based on a class, that object automatically gets all the properties and the methods from that class. That means we can change the…

Contents