Case insensitive switch

suggest change

switch itself can not be parameterised to be case insensitive, but if absolutely required, can behave insensitive to the input string by using toLowerCase() or toUpperCase:

switch (myString.toLowerCase()) {
     case "case1" :
        ...            
     break;
     case "case2" :
        ...            
     break;
}

Beware

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents