Javascript 闭包编译器给出不一致的结果
我的js中包含以下代码:Javascript 闭包编译器给出不一致的结果,javascript,google-closure-compiler,Javascript,Google Closure Compiler,我的js中包含以下代码: var simdFns = { check: function(type) { return function(a) { if (!(a instanceof type.fn)) { throw new TypeError("Argument is not a " + type.name + "."); } return a; } }, splat: function(type) { return function(s)
var simdFns = {
check:
function(type) {
return function(a) {
if (!(a instanceof type.fn)) {
throw new TypeError("Argument is not a " + type.name + ".");
}
return a;
}
},
splat:
function(type) {
return function(s) { return simdSplat(type, s); }
},
replaceLane:
function(type) {
return function(a, i, s) { return simdReplaceLane(type, a, i, s); }
},
//and so on...
};
在js文件上运行带有高级优化的闭包编译器时,生成的代码如下所示:
var mka = {check: /*some code */, N:/* some code */, Qq:/* some code */}
我的问题是,为什么它会更改JSON对象中其余条目(splat
,replaceLane
)的名称,而不会更改check
字段的名称
有什么方法可以避免这种情况吗?编译器常见问题解答中介绍了这一点。我相信。只需搜索外部编译器和闭包编译器这在编译器的常见问题解答中有介绍。我相信。只需搜索外部和闭包编译器