{"action":"closed","issue":{"url":"https://api.github.com/repos/latentflip/loupe/issues/8","repository_url":"https://api.github.com/repos/latentflip/loupe","labels_url":"https://api.github.com/repos/latentflip/loupe/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/latentflip/loupe/issues/8/comments","events_url":"https://api.github.com/repos/latentflip/loupe/issues/8/events","html_url":"https://github.com/latentflip/loupe/issues/8","id":172036536,"number":8,"title":"Problem with setInterval and setTimeout","user":{"login":"asaadsaad","id":4261272,"avatar_url":"https://avatars.githubusercontent.com/u/4261272?v=3","gravatar_id":"","url":"https://api.github.com/users/asaadsaad","html_url":"https://github.com/asaadsaad","followers_url":"https://api.github.com/users/asaadsaad/followers","following_url":"https://api.github.com/users/asaadsaad/following{/other_user}","gists_url":"https://api.github.com/users/asaadsaad/gists{/gist_id}","starred_url":"https://api.github.com/users/asaadsaad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asaadsaad/subscriptions","organizations_url":"https://api.github.com/users/asaadsaad/orgs","repos_url":"https://api.github.com/users/asaadsaad/repos","events_url":"https://api.github.com/users/asaadsaad/events{/privacy}","received_events_url":"https://api.github.com/users/asaadsaad/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-08-19T01:30:23Z","updated_at":"2016-08-31T14:35:21Z","closed_at":"2016-08-31T14:35:21Z","body":"This code will give wrong results!  not only setInterval issues but it will run f1 before f4! \r\n    setTimeout(function f1(){console.log(1)}, 500);\r\n    console.log(2); \r\n    var intId = setInterval(function f3(){console.log(3)}, 0); \r\n    setTimeout(function f4(){console.log(4)}, 0); \r\n    console.log(5);\r\n    clearInterval(intId);\r\n\r\nBased on Philip explanation, setInterval will at least push a callback function f3() to the queue at least once (async) before the clearInterval clear it from the WebAPI, but in real browser f3 will never run, so basically WebAPI will not start working on what we push to it until we finish the Stack!"}}
{"actor":{"display_login":"asaadsaad"}}