jeudi 23 juillet 2015

If (array variable) syntax valid in Javascript

I've been wondering about this syntax I picked up when attempting to accomplish some functionality using jQuery/javascript and was wondering if this is actually valid syntax or not. It seems to work, but it could be that javascript is just defaulting for true in the if-clause. I assumed it just validates whether or not the array has entries/is a valid array. Can anyone explain to me if the following is valid/invalid and if it is valid, what is it checking exactly?

var arrVariable = new Array();

... push things to array, etc.

if(arrVariable)    {
     ... doing stuff with array.    
}

Aucun commentaire:

Enregistrer un commentaire