2016-08-23 52 views
1

我有一個簡單的函數,我通過Google's Closure Compiler Service跑:Closure編譯器爲我的Javascript函數添加' - '。這是什麼意思?

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 
}; 

這是什麼「短跑衝刺」第二行結尾處的rass?爲什麼我從來沒有見過它?

+0

這意味着'currentIndex - = 1'。 – Siguza

回答

4

這是-- b這是--b預遞減算子。

b = b - 1; 

它拆分到下一行,因爲已經有該行80個字符(最大)。