From the course: Learning ECMAScript 6+ (ES6+)
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Introducing classes - JavaScript Tutorial
From the course: Learning ECMAScript 6+ (ES6+)
Introducing classes
- [Instructor] Classes have long been used in object-oriented programming languages to encourage reusability. For example, if we created some sort of a class called chair, a chair would have certain characteristics and then we could create instances of that chair in our projects. As of around 2015, we now have a way to create and use classes with JavaScript and the syntax is pretty fun to use. So first, let's go ahead and create a class called Vehicle. In it, there's a constructor function and the constructor is basically just going to set up any properties that this class is going to use. So what types of things are common about a vehicle? Well, we're going to have a description of some sort and then a number of wheels. So inside of the constructor, we want to set the value of description to this.description and this.wheels to associate it with the class. Next, I'm going to create a custom method called…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Enhancing object literals2m 8s
-
(Locked)
Creating objects with the spread operator1m 25s
-
(Locked)
Destructuring objects3m 2s
-
(Locked)
Iterating with the for/of loop2m 40s
-
(Locked)
Introducing classes2m 28s
-
(Locked)
Inheritance with JavaScript classes1m 39s
-
(Locked)
Getting and setting class values3m 35s
-
(Locked)
-
-
-