Too much recursion 

Higher Order Javascript


   Subscribe in NewsGator Online    Subscribe in Rojo    Add to Google      Add to My AOL   Subscribe in FeedLounge   Add to netvibes  

Brendan Eich's Roadmap  Standard ECMA-262  Yahoo! UI Library     

Friday, July 07, 2006


~ js ramblings ~

"You can pass a this parameter to setTimeout or setInterval, but it requires a helper function":
setInterval(function (t) {; }, 50, this);
"Notice that the first arg is a function reference, not a string. This may not be well-known, but in combination with (or .apply) and extra trailing args to setInterval (or setTimeout), it does the job."-Brendan Eich

"Use a closure to fix the setInterval problem" -Guido Wesdorp :
animateEl = function(el){
var _this = this;
this.animate = function(){
setInterval(_this.animate(), 50)

"There's another way to call an object's member function in a setInterval or setTimeout call. You have to create a bind() member on the Function object's prototype first:
Function.prototype.bind = function( object )
var method = this;
return function()
method.apply( object );
Then you can 'bind' a member function to a setTimeout call like this (assuming your object has a method named foo)"-Tom Trenka:
setTimeout( this ), 50 );

Frankly, you saved my life with your bind method (I had a too much recursion problem).
I'll be visiting your site again to gather some more valuable information. You truly did a good job.
I Like your blog,will sharing this with my friends, excellent work.
business voip systems
Post a Comment

Links to this post:

Create a Link

<< Home


June 2006   July 2006   August 2006   September 2006  

This page is powered by Blogger. Isn't yours?