Created
February 6, 2020 19:38
-
-
Save Heavyblade/df2fec5763fe0f234347c012041c40cb to your computer and use it in GitHub Desktop.
iteracion.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const items = { | |
"item_1": 1, | |
"item_2": 2, | |
"item_3": 3, | |
"item_4": 4, | |
"item_5": 5, | |
"nombre": "cristian", | |
"apellido": "vasquez" | |
}; | |
console.log("xxxxxxxxxxxxxxx Iteracion each xxxxxxxxx ") | |
for (i in items) { | |
console.log("Key: [" + i + "], valor: " + items[i]); | |
} | |
console.log("xxxxxxxxxxxxxxx Iteracion por los keys xxxxxxxxx ") | |
const keys = Object.keys(items); | |
let x = keys.length; | |
for(i = 0; i<x; i++) { | |
console.log("Key: [" + keys[i] + "], valor: " + items[keys[i]]); | |
} | |
console.log("xxxxxxxxxxxxxxx Solo os items xxxxxxxxx ") | |
for(i=1; i <= 5; i++) { | |
console.log("Key: [item_" + i + "], valor: " + items["item_" + i]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment