edit 1: my question was marked as duplicated but it is not answering my question, i don't want to merge but intersect bar in foo.. If bar holds extra properties, merging bar in foo will result in having foo with 3 properties. what i want is to copy the values of the properties of bar that are also presents in foo object.
I hold two objects
var foo = { id:8, name:"luke" }
var bar = { id:9, name:"vador" }
the view keeps a reference on foo
object, then foo=bar
will not make the view updated as foo
has a new reference to data.
Then my question is how can I intersect bar in foo as to keep foo
's reference ?
something similar to
foo.id = bar.id
foo.name = bar.name
but as foo and bar Object may have a lot of properties this would become tedious to write all manually.
What is the most proper way to intersect without any use of js frameworks ?