Skip to content

Instantly share code, notes, and snippets.

@johnsi15
Created August 9, 2017 15:38
Show Gist options
  • Save johnsi15/1031d5e46d9dcc6279393b3d8e1954f6 to your computer and use it in GitHub Desktop.
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
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