SORU
28 EKİM 2012, Pazar


Nasıl olursa dizi bir öğe varsa, kontrol etmek veya javascript değil mi?

Titanyum ile çalışıyorum

benim kod gibi görünüyor

var currentData = new Array();

if(currentData[index]!==""||currentData[index]!==null||currentData[index]!=='null')
{
    Ti.API.info("is exists  "   currentData[index]);
    return true;
}
else
{   
    return false;
}

Geçen dizin dizi currentData ben

Mevcut olmayan eleman için , hala yukarıdaki kodu kullanarak tespit bulunamam

CEVAP
28 EKİM 2012, Pazar


typeof arrayName[index] === 'undefined' kullanın

yani

if(typeof arrayName[index] === 'undefined') {
    // does not exist
}
else {
    // does exist
}

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Dopelives

    Dopelives

    30 Temmuz 2009
  • Sarah's YouTube Channel

    Sarah's YouT

    27 Temmuz 2009
  • TastyTuts | Creative video tutorials by Gareth David

    TastyTuts |

    6 Temmuz 2011