vendredi 30 juin 2017

Java Script: Array.length expression evaluate to boolean

How to check array length, if I need the expression to evaluate to boolean value as a result? For example:

var myArray = [];
if(!myArray.length){
  return;
}

Or:

vr myArray = [];
if(myArray.length == 0){
  return;
}

Both of the examples work, however I’d like to understand what is the difference?

Aucun commentaire:

Enregistrer un commentaire