News for hackers. Stuff that matters.
Re:Being recruited in the USA by jay_kyburz on Wednesday January 04, 2012 @03:02PM (#3425630)
how do you delay a function to the next tick in javascript?
Re:Being recruited in the USA by andrewem on Wednesday January 04, 2012 @05:44PM (#3426303)
That phrasing isn't very precise, but I presume they mean to use setTimeout and pass a timeout of 0 [0]. That link has some discussion of this use and suggests using window.postMessage instead, at least on "modern browsers", for a suitable definition of modern.

[0] https://developer.mozilla.org/en/DOM/window.setTimeout

Re:Being recruited in the USA by djblaze on Wednesday January 04, 2012 @07:44PM (#3426718)
Im assuming we are talking client-side and 'next tick' means when there is a millisecond of free time. Just use: setTimeout(function, 0)

Technically supplying '0' as the milliseconds is bad in old browsers, so you might want to say 10...but I've used '0' a lot without fail.

Re:Being recruited in the USA by masylum on Wednesday January 04, 2012 @05:49PM (#3426336)
setTimeout(fn, 0);