HighDots Forums  

[newbie] Controllare se un oggetto ha una determinata property

Javascript (Italian) Il linguaggio JavaScript (it.comp.lang.javascript)


Discuss [newbie] Controllare se un oggetto ha una determinata property in the Javascript (Italian) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Giulio Petrucci
 
Posts: n/a

Default [newbie] Controllare se un oggetto ha una determinata property - 12-12-2007 , 05:52 AM






Ciao a tutti,

ho un vettore di oggetti che vanno trattati in maniera diversa a seconda
del tipo. Visto che l'istruzione typeof resituisce sempre e comunque
"object", pensavo di implementare una sorta di type-checking basandomi
sulle property degli oggetti. Come faccio a vedere a run-time se per un
oggetto e' definita una property "pippo"? Potri fare una cosa tipo

Quote:
myObject.pippo == undefined
ma non sarebbe proprio il massimo, visto che alcune properties possono
avere proprio undefined come valore.
Suggerimenti/links?

Grazie in anticipo,
Giulio

--
OnAir:
http://petrux.blogspot.com


Reply With Quote
  #2  
Old   
Giulio Petrucci
 
Posts: n/a

Default Re: [newbie] Controllare se un oggetto ha una determinata property - 12-12-2007 , 06:04 AM






Giulio Petrucci ha scritto:
Quote:
Come faccio a vedere a run-time se per un
oggetto e' definita una property "pippo"?
mi rispondo da solo:
if ("pippo" in myObject)
{
...;
}

Ciao e grazie,
Giulio

--
OnAir: NuoviOrizzontiArtificiali - "0.36 (frequenza stabile)"
http://petrux.blogspot.com


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.