As said in recent comments, string::localeCompare
supports case insensitive comparisons (among other powerful things).
Here's a simple example
'xyz'.localeCompare('XyZ', undefined, { sensitivity: 'base' }); // returns 0
And a generic function you could use
function equalsIgnoringCase(text, other) {
return text.localeCompare(other, undefined, { sensitivity: 'base' }) === 0;
}
Note that instead of undefined
you should probably enter the specific locale you are working with. This is important as denoted in the MDN docs
in Swedish, รค and a are separate base letters
As of time of posting, UC Browser for Android and Opera Mini do not support locale and options parameters. Please check https://caniuse.com/#search=localeCompare for up to date info.