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

202
Views
Why is includes in JavaScript case sensitive?

I recently stumbled upon a bug caused by .includes() method in javascript. I wanted to return the exact result in respect to case-insensitive but for some reason this does not works

["Ford", "BMW", "Fiat"].includes("bmw");
//returns false
//expected result true

I then fixed my issue with the help of .find() like below:

!!["Ford", "BMW", "Fiat"].find(el => el.toUpperCase() === "bmw".toUpperCase());
//returns true

Can someone help me understand why includes does not work in case-insensitive situations ?

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

0

Why would it work case-insensitively? Quoth the MDN:

The includes() method determines whether an array includes a certain value among its entries, returning true or false as appropriate. [...] Note: Technically speaking, includes() uses the sameValueZero algorithm to determine whether the given element is found.

sameValueZero is defined to be Object.is but with +0 and -0 being equal.

That being the case, we can try that out:

> Object.is("bmw", "BMW")
false
> Object.is("bmw", "bmw")
true
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!