mercredi 30 mars 2016

Improve condition code

I've the following code

var oDataEn = aData[0][aProperties[0].split('/')[0]];
if (!(oDataEn != null && oDataEn.results && oDataEn.results.length > 0)) {
    ...
    else

...

This is working OK except when

aData[0] = 'undfiend'

my question is if there a better way to write it instead of just adding before

 if(aData[0] != null)
  {
    var oDataEn = aData[0][aProperties[0].split('/')[0]];
  }

Aucun commentaire:

Enregistrer un commentaire