Why is synchronous sleep function not made async by being inside promise?
I'm trying to wrap my head around promises, and how JavaScript works with it's queue and event loop etc. I thought that if I put a slow synchronous function inside a promise, that slow sync function would be delegated to the background and I could use .then to deal with it when it was done. function syncSleep(ms){ var end = new Date().getTime() + ms; var start = new Date().getTime(); while (start < end) { start = new Date().getTime(); } } function p() { return new Promise(function(resolve) { syncSleep(5000); resolve("syncSleep done!"); }); } p().then( function(s) { var div = document