Fixed typo issue in Iterate Over All Properties
This commit is contained in:
		
				
					committed by
					
						 mrugesh mohapatra
						mrugesh mohapatra
					
				
			
			
				
	
			
			
			
						parent
						
							bb9b6b5826
						
					
				
				
					commit
					0d5fec5e21
				
			| @@ -1,4 +1,4 @@ | |||||||
| --- | --- | ||||||
| id: 587d7daf367417b2b2512b7d | id: 587d7daf367417b2b2512b7d | ||||||
| title: Iterate Over All Properties | title: Iterate Over All Properties | ||||||
| challengeType: 1 | challengeType: 1 | ||||||
| @@ -8,7 +8,7 @@ challengeType: 1 | |||||||
| <section id='description'> | <section id='description'> | ||||||
| You have now seen two kinds of properties: <code>own</code> properties and <code>prototype</code> properties. <code>Own</code> properties are defined directly on the object instance itself. And <code>prototype</code> properties are defined on the <code>prototype</code>. | You have now seen two kinds of properties: <code>own</code> properties and <code>prototype</code> properties. <code>Own</code> properties are defined directly on the object instance itself. And <code>prototype</code> properties are defined on the <code>prototype</code>. | ||||||
| <blockquote>function Bird(name) {<br>  this.name = name;  //own property<br>}<br><br>Bird.prototype.numLegs = 2; // prototype property<br><br>let duck = new Bird("Donald");</blockquote> | <blockquote>function Bird(name) {<br>  this.name = name;  //own property<br>}<br><br>Bird.prototype.numLegs = 2; // prototype property<br><br>let duck = new Bird("Donald");</blockquote> | ||||||
| Here is how you add <code>duck’s</code> <code>own</code> properties to the array <code>ownProps</code> and <code>prototype</code> properties to the array <code>prototypeProps</code>: | Here is how you add <code>duck</code>'s <code>own</code> properties to the array <code>ownProps</code> and <code>prototype</code> properties to the array <code>prototypeProps</code>: | ||||||
| <blockquote>let ownProps = [];<br>let prototypeProps = [];<br><br>for (let property in duck) {<br>  if(duck.hasOwnProperty(property)) {<br>    ownProps.push(property);<br>  } else {<br>    prototypeProps.push(property);<br>  }<br>}<br><br>console.log(ownProps); // prints ["name"]<br>console.log(prototypeProps); // prints ["numLegs"]</blockquote> | <blockquote>let ownProps = [];<br>let prototypeProps = [];<br><br>for (let property in duck) {<br>  if(duck.hasOwnProperty(property)) {<br>    ownProps.push(property);<br>  } else {<br>    prototypeProps.push(property);<br>  }<br>}<br><br>console.log(ownProps); // prints ["name"]<br>console.log(prototypeProps); // prints ["numLegs"]</blockquote> | ||||||
| </section> | </section> | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user