You are currently viewing IgnoreCase in JavaScript With Example code

IgnoreCase in JavaScript With Example code

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.


let pattern1 = /Wonderdevelop/;
let pattern2 = /WD/i;
document.write(pattern1.ignoreCase); //false
document.write(pattern2.ignoreCase); //true
  1. Here, we have created two variables namely pattern1, and pattern2.
  2. We assigned the first variable pattern1 to “/Wonderdevelop/” and pattern2 to ” /WD/i”.
  3. Note that pattern2 has an “i-modifier” and pattern1 doesn’t have an “i-modifier”.
  4. So, ignoreCase returns false for pattern1 and true for pattern2.

Leave a Reply