I try to use new Function() in a calculator and I find it does not have access to the arguments I’m passing to the function it’s in. I’m using it like this:
function go(a, b, c) {
return new Function('return a + b + c')();
}
go(4, '/', 2);
But it is not working because it says that a is undefined. Is there any way to get around this?
You probably want:
But this isn’t the correct way to go. Make a distinct function for each action you’re supporting.