Tuesday, June 23, 2015

javascript check existence of nested object

Often, when you use a.b.c.value... the browser reports "Uncaught TypeError: Cannot read property 'value' of undefined"

It is because b does not have property c or c is undefined. It sucks if I need check if b is defined, then check if c is defined...


Here is my solution

No comments:

Post a Comment