I want my user input to overwrite the defaults, but have the defaults fill in the blank if the data is not there. Like so:
var userInput={
name:"Pat",
color: "green"
}
var defaults={
name:"Trevor",
color: "blue",
state: "washington"
}
var finalObject=mergeObjects(userInput,defaults);
//Should produce:
{
name:"Pat",
color: "green",
state: "washington"
}
Is this kind of merging/overwriting possible with jQuery? I did see this question but it works with arrays and does not overwrite like I need it to.
Any ideas?