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

108
Views
Why I can add into Set the same arrays?

I can add into Set exactly the same arrays, but Set mustn't add elements that already exist in this Set. Set must store only unique values. But Why am I able to add these?

let s = new Set();
s.add([1]);
s.add([1]);
s.add([1]);

console.log(s);   //Set(3) {Array(1), Array(1), Array(1)}

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

0

The problem with the Set object in ES6 is that the equality check is based on comparing the actual reference of inserted objects. Thus, when inserting multiple Arrays with the exact same content, it treats them as non-identical as the underlying object reference differs. Same goes for other objects. Primitives on the other hand are compared based on their values.

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!