How do I refer to the module scope from within an ES 6 module?

Viewed 338

In a browser based environment, how would I refer to a variable inside module-level scope if it had the same name as a function parameter within the module?

For e.g. if I had the following:

Module Foo

let thisFoo = undefined;

export function do(foo) {
  thisFoo = foo;
}

I could assign the value of the function parameter foo to the module-scoped variable thisFoo because they are named differently.

But what if I had named the module level variable also by the same name as the function parameter, how would I refer to the module level variable?

Module Foo

let foo = undefined;

export function do(foo) {

  // I'd like to refer to the module level variable foo
  // for the LHS, and assign to it the function level
  // variable foo

  // ???
  // obviously, doesn't make any sense
  foo = foo;

  // this would still refer to the window object, right?
  this.foo = foo;
}
0 Answers
Related