[Proposal] ignoreCase method

Robert Wozniak wozniakj.robert at gmail.com
Wed Jun 27 10:50:07 UTC 2018

Hi everyone,

ignoreCase - JavaScript proposal

It's a proposal to implement a new function to compare two strings but
without case sensitivity.

The proposal is bringing an important function, which is being used in
Java. Many times in my career I had to compare two strings but ignore case

I had to convert it first and then I could compare. I'd like developers to
be able to use the function and compare two strings without worrying about
case sensitivity.
<https://github.com/robertjwozniak/ignoreCase#1-syntax>1. Syntax

String.prototype.ignoreCase = function(value, arrayOfStrings) {
    var secondOption = value.toLowerCase() ||
    var firstOption = this.valueOf().toLowerCase();
    if(typeof secondOption === 'object') {
        for(var i = 0, l = arrayOfStrings.length; i < l; i++) {
            if(firstOption === secondOption[i]) {
                return true;
    } else {
        if(firstOption === secondOption) {
            return true;
        } else {
            return false;

Above code presents *ignoreCase* function and what's happening inside.

The function takes two parameters:

(value, arrayOfStrings)
"value" parameter

The value parameter is the string which is going to be compared with the
parent string chosen by the developer, for example:

const stringOne = "Matheus";stringOne.ignoreCase("matheus"); // true;

"arrayOfStrings" parameter

The "arrayOfStrings" parameter is an array of strings, which are going to
be compared with the parent string chosen by the developer. Once the parent
string equals one of the strings in an array, it will return true and stops
iterating through.


const stringOne = "Matheus";const manyStrings = ['robert', 'lucas',
'matheus'];stringOne.ignoreCase('', manyStrings) // true;

<https://github.com/robertjwozniak/ignoreCase#2-response>2. Response

The function is going to return true or false. The result depends on
equality between chosen strings.
<https://github.com/robertjwozniak/ignoreCase#3-how-it-works>3. How does it

The function converts all of the strings, which the developer chose to the
lower case. After performing the previous operation, it compares all of
them. If at least one, equals the provided parent string, then the function
returns true.

You can the proposal on my GitHub:

Robert Wozniak
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180627/f244dfcd/attachment.html>

More information about the es-discuss mailing list