![](/img/trans.png)
[英]What does it mean to spread a function. Are normal functions iterable in javascript
[英]Closure compiler added '--' to my Javascript function. What does it mean?
我通過Google的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
};
第二行末尾的“破折號”是什么? 為什么我從未見過?
-- b
是--b
預減運算符。
如同
b = b - 1;
在下一行將其拆分,因為該行上已經有80個字符(最多)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.