语法
let func = new Function ([arg1, arg2, …argN], functionBody);
最后一个参数必须是函数体,其余参数作为传递给函数体的参数
例如:
let sum = new Function('a', 'b', 'return a + b');
console.log(sum(1, 2)); // the result is 3
函数体的数据格式是字符串
语法
let func = new Function ([arg1, arg2, …argN], functionBody);
最后一个参数必须是函数体,其余参数作为传递给函数体的参数
例如:
let sum = new Function('a', 'b', 'return a + b');
console.log(sum(1, 2)); // the result is 3
函数体的数据格式是字符串