dimanche 23 juillet 2017

Meaning of if(something.length) in jQuery

I was parsing some smooth-scrolling code online (at http://ift.tt/1zU18Ut) and found the line if (target.length) {some stuff}. Doesn't the .length operator return an integer? How does this work with the if() statement, as I thought they take only true/false values? The same target.length was used as the condition for a ternary statement slightly earlier in the code.

Aucun commentaire:

Enregistrer un commentaire