4

I have a setTimeout, and I want to be able to use a variable as the timer:

var that = this;
var time = this.spawnTime;

setTimeout( function(time){ 
    that.SpawnCounter();
}, time);

This doesn't seem to do the trick. Any ideas why?

Thanks

Oliver Jones
  • 1,420
  • 7
  • 27
  • 43

1 Answers1

2
var that = this;
var time = 1000;

setTimeout( function(time){ 
    that.SpawnCounter();
}, time);

The code above should work. Maybe the problem is that this.spawnTime is not numeric or invaild.

HasanAboShally
  • 18,459
  • 7
  • 30
  • 34