Guest User

Untitled

a guest
Feb 18th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. function outerFunction() {
  2. var counter = 0;
  3.  
  4. return function () {
  5. counter++;
  6. console.log(counter);
  7. }
  8. }
  9.  
  10. var innerReferenceFunction = outerFunction();
  11.  
  12. innerReferenceFunction(); // Console logs : 1
  13. innerReferenceFunction(); // Console logs : 2
  14. innerReferenceFunction(); // Console logs : 3
Add Comment
Please, Sign In to add comment