Created
August 9, 2017 15:38
-
-
Save johnsi15/1031d5e46d9dcc6279393b3d8e1954f6 to your computer and use it in GitHub Desktop.
Tenemos nuevas formas de asignar valores a Arrays y a Objetos. Veamos unos ejemplos
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 [a, b] = ["hola", "mundo"]; | |
console.log(a); // "hola" | |
console.log(b); // "mundo" | |
var obj = { nombre: "Carlos", apellido: "Azaustre" }; | |
var { nombre, apellido } = obj; | |
console.log(nombre); // "Carlos" | |
// Otro ejemplo | |
var foo = function() { | |
return ["175", "75"]; | |
}; | |
var [estatura, peso] = foo(); | |
console.log(estatura); //175 | |
console.log(peso); //75 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment