Javascript undefined properties problems
If you want to create child object in an indefined javascript object, you can use the $parse function of angularJS.
For example:
Let's say I have one object car:
var car={};
Now I want to give this to my object directly: car.engine.piston
Javascript will tell me that I can't read piston of an undefined object because engine is not defined at this point but if I use the $parse function I can do this:
var getter = $parse('car.engine.piston');
var setter = getter.assign;
setter(this, 'value');
And my car.engine.piston will now exist !
Written by Deshayes Yann
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Javascript
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#