Suppose we want the value in variable val.
Scenario 1 :
Var ObjectA = {ObjectB:{val:"text"}}
if we want to get value in val, we can access like ObjectA.ObjectB.val
.
And We'll get "text"
Scenario 2:
Var ObjectB = {}
if I want to get value in val (which is not there), And If I try to access like ObjectA.ObjectB.val
We'll get
Uncaught TypeError: Cannot read property 'val' of undefined at :1:5
The rules are
- we cannot make any values null or initialise any values, We'll simply get these values and must use them.
- If
ObjectB
exists insideObjectA
it doesn't means that val exists inside theObjectB
.
All I want to know is just if there exists a value in variable val or not without disturbing any other things.