For instance, from these two objects :
var object1 = {
"color": "yellow",
"size": null,
"age": 7,
"weight": null
}
var object2 = {
"color": "blue",
"size": 51,
"age": null
}
I want this (object2
overrides object1
except for null
properties or properties he doesn't have):
{
"color": "blue",
"size": 51,
"age": 7,
"weight": null
}
question from:
https://stackoverflow.com/questions/28473574/how-to-merge-objects 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…