Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var example = function() {
- var isFoo, isBar;
- return {
- baz: function(x) {
- if (isFoo) return x + 2;
- else if (isBar) return x - 2;
- },
- get foo () {
- isFoo = true;
- return this;
- },
- get bar () {
- isBar = true;
- return this;
- },
- }
- };
- example().foo.baz(2);
- // 4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement