This Boolean comparison always returns false but it is comparing false == false in my getColumnsFunction(). It should return true, and I have no clue why. Here is the code:
function getModelColumns(exlude, modelName){
var model = Ext.ModelManager.getModel(modelName).create();
var fields = model.fields.items;
for(var x in fields){
console.log( inArray(exlude, fields[x].name == false),
'boolean_compare',
inArray(exlude, fields[x].name));
}
}
function inArray(arr,val){
for(var x in arr){
if(arr[x] === val)
return true;
}
return false;
}
Here is what is in console.log() for all fields in that for loop:
false "boolean_compare" false
They are both equal to false, why they heck does that boolean comparison return false?
Edit: forgot a ‘(‘ it should be inArray(exlude, fields[x].name ) == false
This expression:
will first compare the name to
false, and as they are not equal it will callinArray(exclude, false). Unless it’s an array containing the valuefalseit will always return false.I think that you want:
which will search for the name in the array, then compare the result to
false.