To check if two strings are equal ignoring case in JavaScript, TypeScript, and PHP, you can convert both strings to lowercase or uppercase using the toLowerCase
or toUpperCase
methods and then compare them.
In this example,
str1
and str2
with different cases, such as "Hello"
and "hello"
.toLowerCase
or toUpperCase
methods.===
or ==
operator for strict or loose equality checking, respectively.true
if the strings are equal ignoring case, and false
otherwise.// Equality Check Ignoring Case in JavaScript
let str1 = "Hello";
let str2 = "hello";
let result = str1.toLowerCase() === str2.toLowerCase();
console.log(`Strings are equal ignoring case: ${result}`);
Strings are equal ignoring case: true
In this tutorial, we learned How to check if Two Strings are Equal ignoring case in JavaScript language with well detailed examples.