Created
February 24, 2020 22:22
-
-
Save grekodev/b204edef856e7ca7a3d1f7dc6a89f0b3 to your computer and use it in GitHub Desktop.
js protip argumentos
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
// function crearPersona(nombre, apellido) { | |
// return { nombre, apellido }; | |
// } | |
const crearPersona = (nombre, apellido) => ({ nombre, apellido }); | |
const persona = crearPersona("Brayan", "Pastor"); | |
console.log(persona); | |
function imprimeArgumentos() { | |
console.log(arguments); | |
} | |
const imprimeArgumentos2 = (edad, ...args) => { | |
console.log({ edad, args }); | |
return args; | |
}; | |
const [casado, vivo, nombre, saludo] = imprimeArgumentos2( | |
10, | |
true, | |
false, | |
"brayan", | |
"hola" | |
); | |
console.log({ casado, vivo, nombre, saludo }); | |
const { apellido: nuevoApellido } = crearPersona("Brayan", "Pastor"); | |
console.log({ nuevoApellido }); | |
const tony = { | |
nombre: "Tony Start", | |
codeName: "iroman", | |
vivo: false, | |
edad: 40, | |
trajes: ["Mark 1", "Mark 2", "Hulkbuster"] | |
}; | |
const imprimePropiedades = ({ nombre, codeName, vivo, edad = 15, trajes }) => { | |
console.log({ nombre }); | |
console.log({ codeName }); | |
console.log({ vivo }); | |
console.log({ edad }); | |
console.log({ trajes }); | |
}; | |
imprimePropiedades(tony); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment