所以我看了一下控制SO廣告頁面上的計數器的代碼。然後我看到了這一行發生在i-->
。這是做什麼的?i - > opeator在JavaScript中做了什麼?
這裏是全碼:
$(function(){
var visitors = 5373891;
var updateVisitors = function()
{
visitors++;
var vs = visitors.toString(),
i = Math.floor(vs.length/3),
l = vs.length % 3;
while (i-->0) if (!(l==0&&i==0)) // <-------- Here it is!!!
vs = vs.slice(0,i*3+l)
+ ','
+ vs.slice(i*3+l);
$('#devCount').text(vs);
setTimeout(updateVisitors, Math.random()*2000);
};
setTimeout(updateVisitors, Math.random()*2000);
});
這顯然是從http: //stackoverflow.com/questions/1642028/what-is-the-name-of-this-operator – 2010-01-09 21:05:51
這個問題是關於Javascript。你參考的是關於C/C++。這是真的,他們是相似的,甚至可能複製,但我認爲這是一個足夠公平的變體,因爲它要求一種不同的語言。 – 2010-01-09 23:07:23
@Rob Levine:太棒了!我會針對支持後減量運算符和大於運算符的每種編程語言發佈類似的問題:-P(以及支持前減量和小於運算符xD的每種語言) – 2010-01-10 23:08:01