Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. (async ()=>{
  2. let i=0;
  3. while (1) {
  4. await sleep(1);
  5. console.log(i++);
  6. }
  7. })();
  8. function sleep(ms){
  9. return new Promise(function (resolve, reject) {
  10. setTimeout(()=>{
  11. resolve();
  12. },ms);
  13. })
  14. }
  15.  
  16. Uncaught (in promise) TypeError: Cannot convert undefined or null to object
  17. at eval (userscript.html?id=4ef091f1-f006-441d-bf58-4bd22750f636:24)
  18. at new Promise (<anonymous>)
  19. at sleep (userscript.html?id=4ef091f1-f006-441d-bf58-4bd22750f636:23)
  20. at eval (userscript.html?id=4ef091f1-f006-441d-bf58-4bd22750f636:18)
  21. after nearly 3k iterations.
  22.  
  23. (function() {
  24. 'use strict';
  25.  
  26. function doWork(){
  27. console.log(doWork.i++);
  28. setTimeout(doWork,1);
  29. }
  30. doWork.i=0;
  31. doWork();
  32.  
  33. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement