#How would you apply property value transformations on object A using values from object B?

9 messages · Page 1 of 1 (latest)

nocturne swan
#
let objA = {
    "propA": true,
    "propB": {
        "innerPropA": true
    },
    "innerPropA": false
};

let objB = {
    "propA": false,
    "propB": {
        "innerPropA": false
    },
    "innerPropA": true,
    "newProp": "a new prop from objB"
};

let outputObj = {
    "propA": false, // Changed from `true` to `false` via transformation
    "propB": {
        "innerPropA": false // Changed from `true` to `false` via transformation
    },
    "innerPropA": true,
    "newProp": "a new prop from objB"
}
#

How would you apply property value transformations on object A using values from object B?

thick geyser
#

not too sure about what you are asking

#

want to create a function that takes objA and some transformation function, and return objB as the result of those transformations?

#

@nocturne swan

nocturne swan
#

@thick geyser no quite

#

Given objA and objB, I'd like to produce outputObj

#

Kind of like a hierarchical merge function, if that makes sense

#

You know what, I think outputObj = { ...objA, ...objB } solves it