Use this
in the design is intended to store the value this
at the point setInterval
for the actual callback performed at a given interval. Without saving manually this
, I would become the owner of the function at the point setInterval
.
Here is a very good article on this subject.
Another way that can be done, maybe a little clearer, is the following
var self = this
this.handle = setInterval(function() { alert(self.Name); }, 5000);
source
share