Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

138
Views
Partially replace value of key-val pair in an object

Given I have the following object:

let obj = { 
    cat: "paws",
    dogs: {
        lab: "Christopher",
        otherLab: "Lady Buba"
    }
}

let objTwo = {
    dogs: {
        lab: "some new name"
    }
}

How can I merge the above two objects so that the final result is:

{
    cat: "paws",
    dogs: {
        lab: "some new name",
        otherLab: "Lady Buba"
    }
}

I've attempted to use spread operators with let finalObj = {...obj, ...objTwo}, but this entirely replaces the value of dogs, so that the end result is:

{
    cat: "paws",
    dogs: {
        lab: "some new name",
    }  
}

which isn't what I want.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!