I think this might work, give it a try:

Obj.sortby = Obj.sortby || 'time';

-- Josh

-----Original Message-----
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf 
Of Alexandre Plennevaux
Sent: Wednesday, February 18, 2009 9:07 AM
To: Jquery-en
Subject: [jQuery] default value of an object's property


hi there,

a quick question: i'm using an object to pass a series of variables.
Sometimes, i test for a specific property, which might not exist.
I can't seem to find the right way, i tried

 Obj.sortby = (typeof Obj.sortby == 'undefined' || Obj.sortby==''
||Obj.sortby == null) ? 'time' : Obj.sortby;


but everytime that property "sortby" hasn't been set, firebug returns
it as "null"

can you clear that up for me?

Thanks a lot!

Alexandre

Reply via email to