Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
const window = {
a: 1
global = new Proxy(global, {
get(target, prop, receiver) {
if (target[prop] !== undefined) {
return target[prop];
return window[prop];
// Will be caught by proxy
// Will not be caught by proxy. I'm _guessing_ the
// [[Get]] slot isn't being used when resolving against the
// global environment record?
// This works as intended. Referencing `a` in the top-level
// calls the getter on the `global` object
Object.defineProperty(global, 'a', {
get() {
return 'this works';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment