It works with normal eval but not with the mathjs parser, here is an example.Thank you.
var scope = {
obj: {
window: window,
prop: 42,
setAge: function () {
var myJsName = "testff";
return function () {
return myJsName;
}
}
},
};
console.log(scope.obj.setAge()());
// retrieve properties using dot notation or bracket notation
function evalInContext(js, context) {
//# Return the results of the in-line anonymous function we .call with the passed context
return function () { return eval(js); }.call(context);
}
console.log(evalInContext('scope.obj.setAge()()', scope))
console.log(math.eval('obj.setAge()()', scope));
It works with normal eval but not with the mathjs parser, here is an example.Thank you.