Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Cannot read property 'xxx' of null"

I've got a document fragment with children that I want to loop over (when possible). This is causing an error "Cannot read property 'xxx' of null".

How do I test if this will be the case?

like image 203
Matrym Avatar asked Apr 26 '10 07:04

Matrym


1 Answers

You may want to do the following:

if ((documentFragment !== null) && documentFragment.hasOwnProperty('xxx')) {
    // handle property xxx of documentFragment as required
}
like image 136
Daniel Vassallo Avatar answered Nov 18 '22 23:11

Daniel Vassallo