Advertisement
Aliendreamer

closure js

Nov 13th, 2019
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var once =async function() {
  2.     if(once.done){
  3.         console.log("doing it on realease of done")
  4.         return
  5.     };
  6.     once.done = true;
  7.     await inner().then((result) =>{
  8.         console.log(result)
  9.         once.done =false})
  10. };
  11.  
  12. const inner =async function(){
  13.     setTimeout(await  inner,5000)
  14.     clearTimeout(inner);
  15.     return "Doing it once";
  16. }
  17. once();
  18. once();
  19. once();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement