Last active
September 11, 2018 16:51
-
-
Save rafagarcia/30539f465def48726eb346e476d3b249 to your computer and use it in GitHub Desktop.
JS Bin// source http://jsbin.com/savexuv
This file contains hidden or 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
// Destructuring nested object | |
var car = { | |
model: 'bmw 2018', | |
engine: { | |
v6: true, | |
turbo: true, | |
vin: 12345 | |
} | |
} | |
const modelAndVIN = ({model, engine: {vin}}) => { | |
console.log(`model: ${model} vin: ${vin}`); | |
} | |
modelAndVIN(car); | |
// merge objects | |
let object1 = { a:1, b:2, c:3 } | |
let object2 = { b:30, c:40, d:50} | |
let merged = {...object1, ...object2} //spread and re-add into merged | |
console.log(merged); // {a:1, b:30, c:40, d:50} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment