有没有办法像 eval 一样为 function
运算符设置别名而不需要太多开销?我想写
fn test() { ... }
代替
function test() { ... }
去除压缩代码中的一些字节。只是好奇。
最佳答案
Is there a way to alias function operator without too much overhead?
没有。
当然,除非您使用的是 ECMAScript 6,它应该包含所谓的 "fat arrow" syntax。 :
var test = (arg1, arg2) => arg1 + arg2;
在那之前,你会不断地声明:
var test = function (arg1, arg2) { return arg1 + arg2 };
或
function test(arg1, arg2) {
return arg1 + arg2;
}
关于javascript - 函数运算符可以别名吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16286272/