Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (async ()=>{
- let i=0;
- while (1) {
- await sleep(1);
- console.log(i++);
- }
- })();
- function sleep(ms){
- return new Promise(function (resolve, reject) {
- setTimeout(()=>{
- resolve();
- },ms);
- })
- }
- Uncaught (in promise) TypeError: Cannot convert undefined or null to object
- at eval (userscript.html?id=4ef091f1-f006-441d-bf58-4bd22750f636:24)
- at new Promise (<anonymous>)
- at sleep (userscript.html?id=4ef091f1-f006-441d-bf58-4bd22750f636:23)
- at eval (userscript.html?id=4ef091f1-f006-441d-bf58-4bd22750f636:18)
- after nearly 3k iterations.
- (function() {
- 'use strict';
- function doWork(){
- console.log(doWork.i++);
- setTimeout(doWork,1);
- }
- doWork.i=0;
- doWork();
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement