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

72
Views
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
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!