

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: Classes
incomplete
2: Private Properties
incomplete
3: Static Methods
incomplete
4: Getters and Setters
incomplete
5: Inheritance
incomplete
6: Super
incomplete
This lesson's interactive features are locked, please to keep using them
Classes in JavaScript are a template for creating objects. As we learned, unlike many other languages, it's easy to create JavaScript objects without classes, but that doesn't mean classes aren't useful.
class User {
constructor(name, age) {
this.name = name;
this.age = age;
}
}
const user = new User("Lane", 100);
class declaration creates a new classconstructor method is a special method that's called when a new instance of the class (object) is creatednew keyword calls the constructor method and creates a new instance of the classTextio messages include three properties:
recipient: The person receiving the message.sender: The person sending the message.body: The content of the message.Complete the Message class by adding a constructor that initializes these three properties.