“Cannot read property 'xxx' of null”
-
01-10-2019 - |
Question
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?
Solution
You may want to do the following:
if ((documentFragment !== null) && documentFragment.hasOwnProperty('xxx')) {
// handle property xxx of documentFragment as required
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow