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