Created
August 16, 2019 23:00
-
-
Save parzibyte/4d9e2122108dc6181f1f80c3bfe455ff to your computer and use it in GitHub Desktop.
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
/** | |
* Convertir un objeto a un arreglo | |
* en JavaScript | |
* | |
* @author parzibyte | |
* | |
* https://parzibyte.me/blog | |
*/ | |
let alumnosConCalificaciones = { | |
"Luis": 100, | |
"Pedro": 90, | |
"María José": 100, | |
"John Galt": 99 | |
}; | |
// Object.entries convierte tanto clave y valor. Cada | |
// par es convertido a un arreglo. Al final tenemos un array de arrays | |
let arregloDeClavesYValores = Object.entries(alumnosConCalificaciones); | |
console.log("Claves y valores: ", arregloDeClavesYValores); | |
/* | |
Salida: | |
Claves y valores: [ [ 'Luis', 100 ], | |
[ 'Pedro', 90 ], | |
[ 'María José', 100 ], | |
[ 'John Galt', 99 ] ] | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment