How to modify the scope chain without `with` ?
Coroutines
coroutines at gmail.com
Tue Feb 16 18:10:20 UTC 2016
On Tue, Feb 16, 2016 at 9:57 AM, /#!/JoePea <joe at trusktr.io> wrote:
> You could
>
> ```js
> let {cos, PI} = Math
>
> console.log(cos(PI))
> ```
Oh I agree there - if you're only using a few functions from a module
it makes sense to create local references to them. I just thought
something like this would be nice if you are drawing upon 20+
functions from Math and you don't want to write "Math." everywhere.
Even "m.".
```js
tmp = Object.assign({}, Math);
tmp = Object.setPrototypeOf(tmp, _ENV);
_ENV = tmp; # "global" scope chain would be: Math -> previous module
scope object
exports.someFunction = (x) => cos(PI);
...
...
...
```
More information about the es-discuss
mailing list