Tuesday, April 08, 2008

I AM BACK

Ok I agree that it has been a really really long time since I have updated this blog. I am back now and I hope to update this blog as frequently as I wanted it to be.

Here is a good tip on javascript -:

Javascript: The Hidden Power Of setTimeout()

Many people don't know that the first argument for the setTimeout (and setInterval) function doesn't have to be a string. It is more powerful when you send a function pointer or a reference to a function (passing it by name).

Instead of

setTimeout( "myLoop()", 700 );

do it this way

setTimeout( myLoop, 700 );

Similarly for function pointer or reference

instead of

setTimeout( "myLoop(Mycounter)", 700 );

do it this way

setTimeout( function() { myLoop(Mycounter); }, 700 );

Happy coding ...

No comments: