Search⌘ K
AI Features

Exercise on the Reflect API

Explore practical exercises that help you understand the Reflect API in JavaScript ES6. Learn to create classes, use Reflect methods like apply, set, and deleteProperty to manipulate objects dynamically, and extend prototypes. This lesson equips you with hands-on experience for managing object properties and methods effectively.

Exercise 1:

Create a Movie class, and initialize the title (String) and movieLength (Number) properties in the constructor. Create a toString method that prints the movie out using the following format:

${this.title} (${this.movieLength} minutes)
Node.js
class Movie {
constructor( title, movieLength ) {
//Write your code here
}
toString() {
return "Your Answer";
}
};

Exercise 2:

Use Reflect.apply to call the ...