Ignorecase in Javascript
Learn ignorecase in javascript with a sample example.
ignoreCase is one of the methods in javascript. It is used to find the “i-modifier” in the given JS variables. ignore-case returns always boolean value. It returns true if the “i-modifier” is present and otherwise it returns false.
Example:
let pattern1 = /Wonderdevelop/;
let pattern2 = /WD/i;
document.write(pattern1.ignoreCase); //false
document.write(pattern2.ignoreCase); //true
- Here, we have created two variables namely pattern1, and pattern2.
- We assigned the first variable pattern1 to “/Wonderdevelop/” and pattern2 to ” /WD/i”.
- Note that pattern2 has an “i-modifier” and pattern1 doesn’t have an “i-modifier”.
- So, ignoreCase returns false for pattern1 and true for pattern2.