-
-
Save nikosantis/680b78fbe6c43cb127a300a02241dfb8 to your computer and use it in GitHub Desktop.
Object.assing, spread operator
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
const perfil = { | |
nombre: 'Nikolas', | |
info: { | |
direccion: 'Nataniel Cox 1200' | |
} | |
} | |
const region = { | |
pais: 'Chile', | |
info: { | |
coordenadas: 'coor 123' | |
} | |
} | |
const social = { | |
twitter: '@nikosantise', | |
nombre: 'Ninja Pro' | |
} | |
// const result = Object.assign( | |
// {}, | |
// perfil, | |
// region, | |
// social, | |
// { | |
// info: Object.assign( | |
// {}, | |
// perfil.info, | |
// region.info | |
// ) | |
// } | |
// ) | |
const result = { | |
...region, | |
...perfil, | |
...social, | |
info: { | |
...perfil.info, | |
...region.info | |
} | |
} | |
console.log(result) | |
const frutasVerdes = [ | |
'kiwi', | |
'uva', | |
'limon' | |
] | |
const frutasRojas = [ | |
'manzana', | |
'fresa', | |
'sandia' | |
] | |
frutasVerdes.push('pera') | |
const frutas = [ | |
...frutasVerdes, | |
'pera', | |
...frutasRojas | |
] | |
console.log(frutas) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment