SORU
26 AĞUSTOS 2008, Salı


Tanımsız bir nesne özelliği tespit

Eğer JavaScript bir nesne özelliği tanımlanmamış ise kontrol etmek en iyi yolu nedir?

CEVAP
6 Ocak 2009, Salı


Kullanımı:

if (typeof something === "undefined") {
    alert("something is undefined");
}

Eğer bir bazı özelliklere sahip değişken bir nesne ise bu gibi aynı şeyi kullanabilirsiniz:

if (typeof my_obj.someproperties === "undefined"){
    console.log('the property is not available...'); // print into console
}

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

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Ammine Getahun

    Ammine Getah

    21 HAZİRAN 2011
  • HER0R

    HER0R

    16 Aralık 2007
  • sebsebdouze

    sebsebdouze

    7 ŞUBAT 2008