Classes
Learn how to create classes and use inheritance to minimize redundancy in your code.
StartKey Concepts
Review core concepts you need to learn to master this subject
Static Methods
Static Methods
class Dog {
constructor(name) {
this._name = name;
}
introduce() {
console.log('This is ' + this._name + ' !');
}
// A static method
static bark() {
console.log('Woof!');
}
}
const myDog = new Dog('Buster');
myDog.introduce();
// Calling the static method
Dog.bark();
Within a JavaScript class, the static
keyword defines a static method for a class. Static methods are not called on individual instances of the class, but are called on the class itself. Therefore, they tend to be general (utility) methods.
What you'll create
Portfolio projects that showcase your new skills
Build a Library
It's time to build fluency in Object-oriented JavaScript. In this next Pro Project, we're going to practice Classes in JavaScript so you can hone your skills and feel confident taking them to the real world. Why? You'll practice utilizing the power of object-oriented programming and implement non repetitive code with concepts like inheritance. What's next? Books-'N-Stuff, checkout service, more JavaScript. You got this!
School Catalogue
It's time to build fluency in Object-oriented JavaScript. In this next Pro Project, we're going to practice Classes in JavaScript so you can hone your skills and feel confident taking them to the real world. Why? You'll gain confidence in extending classes to their subclasses, then linking their shared methods and properties. What's next? NYC schools, a digital catalog, more inheritance. You got this!
How you'll master it
Stress-test your knowledge with quizzes that help commit syntax to memory