0
我有以下JavaScript代碼。在函數更新中,this.connection
解析爲undefined而不是數字。我究竟做錯了什麼?JavaScript範圍問題this.connection
function Net()
{
this.connection = -1;
this.counter = 1;
this.timelastsend = -1;
setInterval(this.update, 3000);
}
Net.prototype.update = function()
{
if (this.connection > 0 && this.timelastsend > 0)
{
var now = new Date().valueOf();
if (now - this.timelastsend > 1000 * 60)
{
}
}
}
確實this.timelastsend也解析爲undefined? – user535617 2011-02-07 14:08:14