Untitled
unknown
plain_text
a year ago
516 B
9
Indexable
Here's the Bird constructor from the previous challenge:
function Bird() {
this.name = "Albert";
this.color = "blue";
this.numLegs = 2;
}
let blueBird = new Bird();
NOTE: this inside the constructor always refers to the object being created.
Notice that the new operator is used when calling a constructor. This tells JavaScript to create a new instance of Bird called blueBird. Without the new operator, this inside the constructor would not point to the newly created object, giving unexpected results. Editor is loading...
Leave a Comment