Skip to content

Instantly share code, notes, and snippets.

@jbt
Created April 6, 2013 12:47
Show Gist options
  • Save jbt/5326000 to your computer and use it in GitHub Desktop.
Save jbt/5326000 to your computer and use it in GitHub Desktop.
Thought Exercise
// 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