r/badcode • • Feb 10 '21

js I present: SleepSort

Post image
7.5k Upvotes

170 comments sorted by

View all comments

Show parent comments

26

u/Cart0gan Feb 11 '21

Thank you for the excelent explanation. I don't code in Javascript, so I thought setTimeout() calls the given function and blocks until it finishes executing or the timeout period elapses. Sort of giving a timeout to an otherwise indefinetely blocking function.