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

74
Vistas
Strict comparison vs. Other comparisons

this might be a dumb question but I was curious if it is faster to use strict comparisons between objects than to compare an identifying property, i.e. an id.

Let's say I have these two functions, which tries to remove an object from an array that they belong to:

// The objects in this array all have unique string `id`s, in addition to other props. 

const removeObject = (array, object) => {
  const index = array.findIndex(o => o === object)
  array.splice(index, 1)
  return object
}

const removeObjectUsingId = (array, object) => {
  const index = array.findIndex(o => o.id === object.id)
  array.splice(index, 1)
  return object
}

Assuming that this operation will be done frequently on large arrays, magnifying the difference between the two comparison operations. Am I right to think that since object comparison is done through comparing the reference (maybe the address?) of the object, it would be faster than comparing two strings?

about 4 years ago · Juan Pablo Isaza
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