2021-02-06 04:42:36 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								---
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								id: 587d7db1367417b2b2512b86
							 
						 
					
						
							
								
									
										
										
										
											2021-03-31 22:38:36 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								title: Restablece una propiedad "constructor" heredada
							 
						 
					
						
							
								
									
										
										
										
											2021-02-06 04:42:36 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								challengeType: 1
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								forumTopicId: 301324
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								dashedName: reset-an-inherited-constructor-property
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								---
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# --description--
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-29 22:47:35 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Cuando un objeto hereda el `prototype`  de otro objeto, también hereda la propiedad del constructor del supertipo.
							 
						 
					
						
							
								
									
										
										
										
											2021-02-06 04:42:36 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-29 22:47:35 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Por ejemplo:
							 
						 
					
						
							
								
									
										
										
										
											2021-02-06 04:42:36 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```js
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function Bird() { }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Bird.prototype = Object.create(Animal.prototype);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								let duck = new Bird();
							 
						 
					
						
							
								
									
										
										
										
											2021-03-29 22:47:35 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								duck.constructor
							 
						 
					
						
							
								
									
										
										
										
											2021-02-06 04:42:36 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-20 22:29:09 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Pero `duck`  y todas las instancias de `Bird`  deberían mostrar que fueron construidas por `Bird`  y no `Animal` . Para ello, puedes establecer manualmente la propiedad del constructor de `Bird`  al objeto `Bird` :
							 
						 
					
						
							
								
									
										
										
										
											2021-02-06 04:42:36 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```js
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Bird.prototype.constructor = Bird;
							 
						 
					
						
							
								
									
										
										
										
											2021-03-29 22:47:35 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								duck.constructor
							 
						 
					
						
							
								
									
										
										
										
											2021-02-06 04:42:36 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# --instructions--
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-29 22:47:35 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Corrige el código para que `duck.constructor`  y `beagle.constructor`  devuelvan sus constructores respectivos.
							 
						 
					
						
							
								
									
										
										
										
											2021-02-06 04:42:36 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# --hints--
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-29 22:47:35 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								`Bird.prototype`  debe ser una instancia de `Animal` . 
						 
					
						
							
								
									
										
										
										
											2021-02-06 04:42:36 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```js
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								assert(Animal.prototype.isPrototypeOf(Bird.prototype));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-29 22:47:35 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								`duck.constructor`  debe devolver `Bird` . 
						 
					
						
							
								
									
										
										
										
											2021-02-06 04:42:36 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```js
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								assert(duck.constructor === Bird);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-29 22:47:35 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								`Dog.prototype`  debe ser una instancia de `Animal` . 
						 
					
						
							
								
									
										
										
										
											2021-02-06 04:42:36 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```js
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								assert(Animal.prototype.isPrototypeOf(Dog.prototype));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-29 22:47:35 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								`beagle.constructor`  debe devolver `Dog` . 
						 
					
						
							
								
									
										
										
										
											2021-02-06 04:42:36 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```js
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								assert(beagle.constructor === Dog);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# --seed--
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								## --seed-contents--
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```js
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function Animal() { }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function Bird() { }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function Dog() { }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Bird.prototype = Object.create(Animal.prototype);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Dog.prototype = Object.create(Animal.prototype);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Only change code below this line
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								let duck = new Bird();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								let beagle = new Dog();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# --solutions--
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```js
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function Animal() { }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function Bird() { }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function Dog() { }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Bird.prototype = Object.create(Animal.prototype);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Dog.prototype = Object.create(Animal.prototype);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Dog.prototype.constructor = Dog;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Bird.prototype.constructor = Bird;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								let duck = new Bird();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								let beagle = new Dog();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```