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

166
Views
JavaScript - How to delete an element from an array using deepmerge

I would like to be able to remove a value from my array but with deepmerge the array values only add up. Does anyone have an idea how to solve this problem?

const dp = require('deepmerge');
const a = { moderation: { administrator_roleIds: [ '863696108285591562', '851483467047763978' ] } };

const b = { moderation: { administrator_roleIds: [ '863696108285591562' ] } };

dp(a, b);
// outpout => { moderation: { administrator_roleIds: [ '863696108285591562', '863696108285591562' ] } } or I want { moderation: { administrator_roleIds: [ '863696108285591562' ] } }

I need to use deepmerge because to modify my object I use a function using deepmerge, it would bother me to create another function knowing that I don't know how to do a deepmerge but inverse version of the merge (by removing items).

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

As per deepmerge definition:

Merges the enumerable properties of two or more objects deeply.

You cant use deepmerge for deleting. Its use case is for merging.

For deleting an element of an array use the normal array methods.

const fruits = ["Banana", "Orange", "Apple", "Mango"];
delete fruits[0];
about 4 years ago · Juan Pablo Isaza Report
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!