var arr = [
{
id:1,
name:"mincoo"
},
{
id:2,
name:"tomorrow"
}
];
//:key
function isContainKey(arr,value,keyName){
for(var i=0;i<arr.length;iPP){
if(arr[i].keyName == value){
return false; //
}
else{
return true; //
}
console.log(arr[i].keyName);
}
}
isContainKey(arr,"tomorrow","name");
what I want:
if the array is detected to contain this element, return true, otherwise return false.
but the screen I wrote here is blank. What"s the reason?