Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. var example = function() {
  2. var isFoo, isBar;
  3.  
  4. return {
  5.  
  6. baz: function(x) {
  7. if (isFoo) return x + 2;
  8. else if (isBar) return x - 2;
  9. },
  10.  
  11. get foo () {
  12. isFoo = true;
  13. return this;
  14. },
  15.  
  16. get bar () {
  17. isBar = true;
  18. return this;
  19. },
  20. }
  21. };
  22.  
  23. example().foo.baz(2);
  24. // 4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement