vendredi 17 août 2018

Which is right way to use below statement performance wise?

Which approach is most recommended. First or Second ?

var x = document.querySelectorAll("span");

// #1:  Console returns false
x.length > 0 && x[0].blur();

// #2:  Console returns undefined
if (x.length > 0) {
  x[0].blur();
}

Aucun commentaire:

Enregistrer un commentaire