Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

73
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda