Posted By

samuelcotterall on 03/11/10


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

nerdfiles


setTimeout() Redux


 / Published in: JavaScript
 

I don’t know how or why this works.

  1. setTimeout({
  2. run: function() {
  3. foo(bar)
  4. }
  5. }.run, 1000);

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: nerdfiles on March 11, 2010

That's pretty.

Picture declaring your object with the "run" method before line 1.

var obj1 = { run: function() { foo(bar); } } setTimeout(obj1.run, 1000);

It's really no different. From the look of it, it appears the object is "anonymous," given your demonstration.

You need to login to post a comment.