is it possible to use string as path ?
instead of _parent._parent.myVar=123;
use something like this:
var path = '_parent._parent';
and then use it as
path.myVar=123';
is it possible to use string as path ?
instead of _parent._parent.myVar=123;
use something like this:
var path = '_parent._parent';
and then use it as
path.myVar=123';
You may use multiple []
.
for your example, you need _parent._parent
:
var path = '_parent';
this[path][path].myVar = 123;
another example:
var path1 = '_parent';
var path2 = 'apple';
this[path1][path2].myVar = 456;
//equals to _parent.apple.myVar = 456;