fix(challenge): Format constructor property in "OOP: Set Constructor"
commit
7a65e16d61
|
@ -507,12 +507,12 @@
|
|||
"id": "587d7daf367417b2b2512b80",
|
||||
"title": "Remember to Set the Constructor Property when Changing the Prototype",
|
||||
"description": [
|
||||
"There is one crucial side effect of manually setting the <code>prototype</code> to a new object. It erased the constructor property! The code in the previous challenge would print the following for <code>duck</code>:",
|
||||
"There is one crucial side effect of manually setting the <code>prototype</code> to a new object. It erased the <code>constructor</code> property! The code in the previous challenge would print the following for <code>duck</code>:",
|
||||
"<blockquote>console.log(duck.constructor)<br>// prints ‘undefined’ - Oops!</blockquote>",
|
||||
"To fix this, whenever a prototype is manually set to a new object, remember to define the constructor property:",
|
||||
"To fix this, whenever a prototype is manually set to a new object, remember to define the <code>constructor</code> property:",
|
||||
"<blockquote>Bird.prototype = {<br> constructor: Bird, // define the constructor property<br> numLegs: 2,<br> eat: function() {<br> console.log(\"nom nom nom\");<br> },<br> describe: function() {<br> console.log(\"My name is \" + this.name); <br> }<br>};</blockquote>",
|
||||
"<hr>",
|
||||
"Define the constructor property on the <code>Dog</code> <code>prototype</code>."
|
||||
"Define the <code>constructor</code> property on the <code>Dog</code> <code>prototype</code>."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"function Dog(name) {",
|
||||
|
|
Loading…
Reference in New Issue