let obj = {
sub: {
myFunc: function() {
console.log('check');
}
}
}
let callFunction = 'sub.myFunc'; // Can anyone help me figure out why this doesn't work correctly?
obj[callFunction](); // This works fine, but not with 'sub.myFunc'
obj.sub.myFunc(); // This one works as expected.
I'm looking for a solution that will work generically. Any suggestions on why 'sub.myFunc' is not working? Is there a workaround to make it function properly?