[Javascript] Object Not Defined

Hassan Schroeder hassan at webtuitive.com
Fri Nov 11 11:44:38 CST 2011


On 11/11/11 4:45 AM, Terry Riegel wrote:

 > It would be nice if this did the same thing...
 >
 > function(a){return a.data.items || []};

What makes you think it doesn't? That syntax seems to work fine for
me in a quick test in a Chrome console:

 > var x = function(a){ return a || []; }
undefined
 > x("foo")
"foo"
 > x()
[]
 > x(null)
[]

Or am I misunderstanding your goal?

-- 
Hassan Schroeder ----------------------------- hassan at webtuitive.com
webtuitive design ===  (+1) 408-621-3445   === http://webtuitive.com
http://about.me/hassanschroeder
twitter: @hassan
                           dream.  code.


More information about the Javascript mailing list