Skip to content

Instantly share code, notes, and snippets.

@chrispsn
Created November 11, 2017 22:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrispsn/b0b717348c437fcb282a5f277bb9c3ac to your computer and use it in GitHub Desktop.
Save chrispsn/b0b717348c437fcb282a5f277bb9c3ac to your computer and use it in GitHub Desktop.
Is there a way to allow branches of a nested object to look at other branches of the parent?
'use strict';
module.exports = (function() {
// It would be good to get rid of the my_module declaration entirely
const my_module = {
a: 'abc',
get b() {return 123},
get c() {return my_module.a},
get c2() {return this.a},
get d() {return {
e: [1, 2],
get f() {return my_module.d.e},
get f2() {return this.e},
get g() {return my_module.a},
}},
};
return my_module;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment