Article From:https://segmentfault.com/q/1010000011704619
Question:

Modifying who purchases insurance or gender or fees above requires re-requesting data from the background and then rendering an insurance fee calculation at the bottom, but this data type is complex, with nested arrays nested within objects and possibly objects.
Object.assign Definitely not. How do we merge complex data?

Think about it carefully. It doesn’t seem to matter to me what I’m doing right now. Merge it directly, but if it happens.
var a = {

name: 'lee',
numbers: [1,2,3,4],
teachers: [
    {male: 'zs'},
    {female: 'ls'},
]

}
var b = {

name: 'lee',
numbers: [1,2,3,4],
teachers: [
    {male: 'zss'},
    {female: 'ls'},
    {other: 'xx'}
]

}
Object.assign({}, b, a) After merging, it will directly cover the whole teachers in B.
other: ’xx’, This object is missing. How can we only cover the same thing and keep it different?

Answer 0:

You can try the Immutable.js merge interface.

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *