WebFX WebBoard
Message Thread:
View All Messages
Back to WebFX
 setInterval in an object, chris, July 10, 2003
     Re:setInterval in an object, k, July 11, 2003
         Re:setInterval in an object, Erik Arvidsson, July 11, 2003
             Re:setInterval in an object, Chris, July 13, 2003
             Re:setInterval in an object , tim scarfe, July 12, 2003
                 Re:setInterval in an object , Erik Arvidsson, July 13, 2003
             Re:setInterval in an object, k, July 11, 2003
                 Re:setInterval in an object, Erik Arvidsson, July 11, 2003

Subject: Re:setInterval in an object From: tim scarfe Date: July 12, 2003

And remember that in Erik's top example, the anon function is executed in global scope. Due to the function chain (closures), the oThis variable is still accessible there though. This could possibly lead to security problems depending on the application.

Tim Scarfe

From: Erik Arvidsson
Sent: July 11, 2003
Subject: Re:setInterval in an object

Why not use higher order functions. Much cleaner in my opinion.

function Chris() {
this.method1 = someFunction;
var oThis = this;
window.setInterval(function () { oThis.method1(); }, 1000);
}
var dummy = new Chris();

Or if you forget about IE:

function Chris() {
this.method1 = someFunction;
window.setInterval(function (o) { o.method1(); }, 1000, this);
}
var dummy = new Chris();

erik





Reply
Name: 
Email: 
Subject: 

Enter your reply to this message below. HTML tags are not supported but words that start with http://, ftp:// or mailto: are converted to links.


View All Messages
Back to WebFX