Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

167
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda