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
Fetch values by ignoring a specific one in JavaScript?
To ignore a specific value, use the logical Not (!) operator in if condition and fetch watching you want to include.
Example
var customerDetails=[
{
customerName:"John",
customerAge:28,
customerCountryName:"US"
},
{
customerName:"David",
customerAge:25,
customerCountryName:"AUS"
},
{
customerName:"Mike",
customerAge:32,
customerCountryName:"UK"
}
]
for(var i=0;i<customerDetails.length;i++){
if(customerDetails[i].customerCountryName!="AUS"){
console.log("The country name
is="+customerDetails[i].customerCountryName);
}
}
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo179.js.
Output
This will produce the following output −
PS C:\Users\Amit\javascript-code> node demo179.js The country name is=US The country name is=UK
Advertisements