June 2018
Beginner
288 pages
6h 31m
English
You know how to create a class, but you haven’t seen how to define the body of the constructor. Creating a class defines a no-parameter default constructor, which appears to be empty bodied. But you may want to execute some code as part of object construction. For that we need to define an explicit constructor. That’s exactly what we’ll do next.
Let’s first examine the default constructor that is automatically created when you define a class.
| | class Car {} |
| | |
| | console.log(Reflect.ownKeys(Car.prototype)); |
We created a class named Car, with a default constructor. Then, using the Reflect class’s ownKeys() method, we examine the properties of the Car’s prototype—you’ll learn about Reflect ...
Read now
Unlock full access