Closure 编译器在我的 Javascript 函数中添加了“--”。这是什么意思?
Closure compiler added '--' to my Javascript function. What does it mean?
我有一个简单的函数,我 运行 到 Google's Closure Compiler Service:
var fisherYatesShuffle = function(array) {
var currentIndex = array.length;
var temporaryValue;
var randomIndex;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
};
它给了我以下信息(我打印得很漂亮):
var fisherYatesShuffle = function(a) {
for (var b = a.length, d, c; 0 !== b;) c = Math.floor(Math.random() * b), --
b, d = a[b], a[b] = a[c], a[c] = d;
return a
};
第二行末尾的 'dash dash' rass 是什么?为什么我从来没有见过它?
它是 --
b
,它是 --b
预递减运算符。
同
b = b - 1;
它在下一行拆分,因为该行已经有 80 个字符(最多)。
我有一个简单的函数,我 运行 到 Google's Closure Compiler Service:
var fisherYatesShuffle = function(array) {
var currentIndex = array.length;
var temporaryValue;
var randomIndex;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
};
它给了我以下信息(我打印得很漂亮):
var fisherYatesShuffle = function(a) {
for (var b = a.length, d, c; 0 !== b;) c = Math.floor(Math.random() * b), --
b, d = a[b], a[b] = a[c], a[c] = d;
return a
};
第二行末尾的 'dash dash' rass 是什么?为什么我从来没有见过它?
它是 --
b
,它是 --b
预递减运算符。
同
b = b - 1;
它在下一行拆分,因为该行已经有 80 个字符(最多)。