Created
April 6, 2013 12:47
-
-
Save jbt/5326000 to your computer and use it in GitHub Desktop.
Thought Exercise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Without running this: what gets logged in what order? | |
var a = {}; | |
Object.defineProperty(a, 'a', { get: function(){ | |
console.log('get a'); | |
return function(){ console.log('a'); return a; }; | |
}}); | |
Object.defineProperty(a, 'b', { get: function(){ | |
console.log('get b'); | |
return function(){ console.log('b'); return a; }; | |
}}); | |
Object.defineProperty(a, 'c', { get: function(){ | |
console.log('get c'); | |
return function(){ console.log('c'); return a; }; | |
}}); | |
Object.defineProperty(a, 'd', { get: function(){ | |
console.log('get d'); | |
return function(){ console.log('d'); return a; }; | |
}}); | |
Object.defineProperty(a, 'e', { get: function(){ | |
console.log('get e'); | |
return function(){ console.log('e'); return a; }; | |
}}); | |
a.a(a.b()).c(a.d().e()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment