Created
February 16, 2020 14:20
-
-
Save vmussak/283058fa8b2e1b88edb35e9b5b5ce126 to your computer and use it in GitHub Desktop.
Maneiras de obter as keys de um objeto com javasacript
This file contains 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
var meuObjeto = { | |
b: 10, | |
c: 20, | |
d: 30 | |
}; | |
//Utilizando Object.keys | |
var x = Object.keys(meuObjeto); | |
for(var i = 0; i < x.length; i++) { | |
console.log(x[i]) | |
} | |
//Utilizando for...in | |
for(var item in meuObjeto){ | |
console.log(item); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment