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

145
Views
Are object variables with the same address always identical in JavaScript?

This question seems a bit silly but I just wanna confirm my understanding.

  1. I'm learning about comparision in JavaScript and it seems to me that if two ojbects have the same address then they should definitely be equal (b/c basically they are one?). Is this always true?

  2. bonus question: in the case I do want to implement this address comparision (shallow comparision), can I do it in pure JS without Object.is or ===?

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

0

Two objects cannot occupy the same location, either in our physical universe or in the twisted javascript universe. What you can have are two objects whose values are references to the same memory location.

var x = [1, 2, 3]
var y = x

So, the array [1, 2, 3] might be stored in some memory address, let's say it starts at 00A4. The variable x will be stored in some different place in memory, let's say 0108, and the actual value stored in that location is the number 00A4, that represents the memory location of its referenced value. Now, y will be then store in another totally different memory location, let's say 020F, and its value will also be 00A4, the memory location of its referenced value.

  1. Both x and y are variables whose values are references, that ultimately point to the same address. Reference values that point to the same address are always equal when compared.

  2. Javascript doesn't have any low-level semantics like this to manipulate memory addresses. You could do that maybe by using c procedure calls or something.

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!