SHARE
TWEET

Untitled

a guest Feb 17th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function idGenerator() {
  2.     var i = 0;
  3.     return function() {
  4.         return ++i;
  5.     }
  6. }
  7.  
  8. var generator1 = idGenerator();
  9. var generator2 = idGenerator();
  10.  
  11. console.log('generator 1 mówi: ' + generator1());
  12. console.log('generator 2 mówi: ' + generator2());
  13. console.log('generator 1 mówi: ' + generator1());
  14. console.log('generator 1 mówi: ' + generator1());
  15. console.log('generator 2 mówi: ' + generator2());
  16. console.log('generator 1 mówi: ' + generator1());
  17. console.log('generator 1 mówi: ' + generator1());
  18. console.log('generator 2 mówi: ' + generator2());
  19. console.log('generator 1 mówi: ' + generator1());
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top