mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-01-14 13:15:59 +00:00
Added for/in loop JavaScript
Fixing code style
This commit is contained in:
parent
f1711ddd4c
commit
c3914e277b
@ -221,7 +221,7 @@ for (var i = 0; i < 5; i++){
|
|||||||
//The For/In statement loops iterates over every property across the entire prototype chain
|
//The For/In statement loops iterates over every property across the entire prototype chain
|
||||||
var description = "";
|
var description = "";
|
||||||
var person = {fname:"Paul", lname:"Ken", age:18};
|
var person = {fname:"Paul", lname:"Ken", age:18};
|
||||||
for (var x in person) {
|
for (var x in person){
|
||||||
description += person[x] + " ";
|
description += person[x] + " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,8 +229,8 @@ for (var x in person) {
|
|||||||
//and not its prototypes use hasOwnProperty() check
|
//and not its prototypes use hasOwnProperty() check
|
||||||
var description = "";
|
var description = "";
|
||||||
var person = {fname:"Paul", lname:"Ken", age:18};
|
var person = {fname:"Paul", lname:"Ken", age:18};
|
||||||
for (var x in person) {
|
for (var x in person){
|
||||||
if( person.hasOwnProperty( x ) ) {
|
if (person.hasOwnProperty(x)){
|
||||||
description += person[x] + " ";
|
description += person[x] + " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user