在 JavaScript 中通过忽略一个特定值来获取值?
要忽略特定值,请在 if 条件中使用逻辑非 (!) 运算符,并获取想要输入的监视。
示例
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);
}
}要运行上述程序,你需要使用以下命令 −
node fileName.js.
这里,我的文件名是 demo179.js。
输出
这将产生以下输出 −
PS C:\Users\Amit\javascript-code> node demo179.js The country name is=US The country name is=UK
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP