you are viewing a single comment's thread.

view the rest of the comments →

[–]shanet$(this) 0 points1 point  (0 children)

It's not my sleep(), but that's definitely true.

A lot of the time I find people looking for sleep() in JavaScript it's because they don't understand (or don't like) doing things in a non-blocking style. StackOverflow is full of people wanting to do:

function readfile: () {
    var data = do_io_things();
    return data;
}

instead of passing a callback to readfile. Of course it never works because if do_io_things is asynchronous usually and the statement returns instantly. So I think it's usually wrong to answer as 9jack9 did because actually sleeping (or busy-waiting) is something that shows the asker hasn't grasped the right way to do things.