javascript case insensitive compare code example
Example 1: Javascript case insensitive string comparison
var name1 = "Taylor Johnson";
var name2 ="taylor johnson";
if(name1.toLowerCase() === name2.toLowerCase()){
}
Example 2: compare string camelcase and lowercase javascript
function sameCase(str) {
return /^[A-Z]+$/.test(str) || /^[a-z]+$/.test(str);
}
Example 3: javascript string insensitive compare
const str1 = '[email protected]';
const str2 = '[email protected]';
str1 === str2;
str1.localeCompare(str2, undefined, { sensitivity: 'accent' });