JS

CASE INSENSITIVE STRING COMPARISON IN JAVASCRIPT

var first = "car"; var second = "CAR";

TO UPPER OR LOWER CASE

01

if (first.toLowerCase() == second.toLowerCase()) { SAME }   if (first.toUpperCase() == second.toUpperCase()) { SAME }

LOCALE COMPARE

02

if (first.localeCompare(second, "en",   { sensitivity: "base" } ) == 0) { SAME }

var first = "car"; var second = "CAR";

var first = "CAR"; var pattern = /^car$/i;

REGULAR EXPRESSION

03

if (pattern.test(first)) { SAME }