【发布时间】:2018-08-02 09:34:26
【问题描述】:
我想知道,为什么 int++ 不工作,但 int+1 工作。有人知道为什么在我的示例中会发生这种情况?有什么区别吗?
function retryFunction(something, count) {
if (!count) {
count = 0;
}
console.log(typeof count);
console.log(count);
if (count < 5) {
return setTimeout(function () {
//working
retryFunction(something, count+1);
//not working
retryFunction(something, count++);
}, 1000)
}
}
retryFunction(null);
【问题讨论】:
-
(无论“不工作”是什么意思),因为在第二种情况下,
count在调用之后被强化了。 -
↑ 这不是同一种语言,但适用。
-
改用 ++count
标签: javascript node.js int