I think (if I am not wrong), that when using && operator, the second parm will not even execute when the first evaluated to false.
So It would be wise to put the parm that will be more likely to be false at first, right?
When looping, like this:
function inArray(fnd,arr){
var i=0,ien=arr.length;
for(;i<ien;i++){
if(i in arr&&arr[i]===fnd){
return i;
}
}
return -1;
}
Which would be better to use?
...
if (i in arr && arr[i] === fnd) {
return i;
}
...
or
...
if (arr[i] === fnd && i in arr) {
return i;
}
...