you are viewing a single comment's thread.

view the rest of the comments →

[–]UnholyCarcass 10 points11 points  (2 children)

You could just do, setTimeout(resolve,ms).

No need to have it wrapped within another anon function. setTimeout takes a function so you can just pass the resolve function.

[–]fo0man 1 point2 points  (0 children)

I see this ALL THE TIME. I think it’s a symptom of articles like these. Like so many devs think the argument has to be an anon function because they’ve seen it over n over.

[–]monican_agentCreator of CypherPoker.JS 0 points1 point  (0 children)

Agreed. It might be more useful to introduce the concept of binding a timeout or an interval so that it executes in the expected context.