【发布时间】:2018-10-17 03:13:01
【问题描述】:
有人写了这个函数来检测鼠标。但我真的不明白它是如何工作的。所以我对这个函数没有几个问题。
document.onmousemove = (function() {
var onmousestop = function() {
/* do stuff */
console.log('STOP');
}, thread;
return function() {
clearTimeout(thread);
console.log(thread);
thread = setTimeout(onmousestop, 500);
};
})();
有一部分我们有 function(){},thread; 那部分实际上是什么意思?函数的}后面的参数是什么意思?
【问题讨论】:
-
就像
var x = 5, y = 6一样,一次声明两个变量,而开头只使用一个var(或let或const)
标签: javascript function