How to do case insensitive string comparison?

flybywire picture flybywire · Jan 26, 2010 · Viewed 855.8k times · Source

How do I perform case insensitive string comparison in JavaScript?

Answer

SLaks picture SLaks · Jan 26, 2010

The simplest way to do it (if you're not worried about special Unicode characters) is to call toUpperCase:

var areEqual = string1.toUpperCase() === string2.toUpperCase();