
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Check for Case Insensitive Values in JavaScript
To check for case insensitive values, use regular expression in JavaScript. Following is the code −
Example
var allNames = ['john','John','JOHN']; var makeRegularExpression = new RegExp(allNames.join( "|" ), "i"); var hasValue = makeRegularExpression.test("JOHN"); console.log("Is Present="+hasValue);
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo130.js.
Output
This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo130.js Is Present=true
Advertisements