Data update
This commit is contained in:
parent
72eb4943cb
commit
4d5544505c
2347 changed files with 62432 additions and 16731 deletions
|
|
@ -1,18 +1,19 @@
|
|||
(() => {
|
||||
'use strict';
|
||||
const base = {
|
||||
"name": "Rocket Skates",
|
||||
"price": 12.75,
|
||||
"color": "yellow"
|
||||
};
|
||||
|
||||
console.log(JSON.stringify(
|
||||
Object.assign({}, // Fresh dictionary.
|
||||
{ // Base.
|
||||
"name": "Rocket Skates",
|
||||
"price": 12.75,
|
||||
"color": "yellow"
|
||||
}, { // Update.
|
||||
"price": 15.25,
|
||||
"color": "red",
|
||||
"year": 1974
|
||||
}
|
||||
),
|
||||
null, 2
|
||||
))
|
||||
})();
|
||||
const update = {
|
||||
"price": 15.25,
|
||||
"color": "red",
|
||||
"year": 1974
|
||||
};
|
||||
|
||||
// While ES6 destructuring may be cleaner, using Object.assign (provided in the original answer) instead is about 15-20% faster.
|
||||
// source: https://jsbench.me/jom7uh9o1t/1
|
||||
|
||||
const final = Object.assign(base, update);
|
||||
// Using ES6 destructuring method: const final = { ...base, ...update };
|
||||
|
||||
console.log(JSON.stringify(final, null, 4));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue