Wait until flag=true
Because javascript in a browser is single threaded (except for webworkers which aren’t involved here) and one thread of javascript execution runs to completion before another can run, your statement: will simply run forever (or until the browser complains about a non-responsive javascript loop), the page will appear to be hung and no other javascript … Read more