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

180
Views
Are we unable to use HTML element literals as hash table keys in JavaScript?

I figured every new instance of an HTML element would be it's own distinct object, but hash tables are telling me differently. If I do: document.createElement("button") === document.createElement("button") I get the expected result of false , but if I do:

let hash = {
    [document.createElement("button")]: "choice 1",
    [document.createElement("button")]: "choice 2"
}

console.log(hash);

then the result is: {[object HTMLButtonElement]: 'choice 2'}, meaning the second button element overwrote the first button element even though they're supposedly different values. Does anyone know why that is? Can we not use elements as distinct keys in a hash table? If so, is there an alternate way of achieving what I have above?

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!