Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

Commit

Permalink
Stage 4, per 2019.10.01 TC39
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Oct 1, 2019
1 parent 3ccb201 commit 282d472
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ECMAScript Proposal, specs, and reference implementation for `globalThis`

Spec drafted by [@ljharb](https://github.com/ljharb).

This proposal is currently [stage 3](https://github.com/tc39/ecma262) of the [process](https://tc39.github.io/process-document/).
This proposal is currently [stage 4](https://github.com/tc39/ecma262) of the [process](https://tc39.github.io/process-document/).

## Rationale
It is difficult to write portable ECMAScript code which accesses the global object. On the web, it is accessible as `window` or `self` or `this` or `frames`; on node.js, it is `global` or `this`; among those, only `this` is available in a shell like V8's `d8` or JavaScriptCore's `jsc`. In a standalone function call in sloppy mode, `this` works too, but it's `undefined` in modules or in strict mode within a function. In such contexts, the global object can still be accessed by `Function('return this')()`, but that form is inaccessible with some CSP settings, such as within Chrome Apps. Below is some code from the wild to get the global object, passed in as the single argument to an IIFE, which works for most cases but won't actually work in `d8` when in a module or in strict mode inside a function (which could be fixed using the `Function` trick):
Expand Down
2 changes: 1 addition & 1 deletion spec.emu
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<script src="./spec.js"></script>
<pre class="metadata">
title: global
stage: 3
stage: 4
contributors: Jordan Harband
</pre>
<emu-clause id="sec-other-properties-of-the-global-object">
Expand Down

0 comments on commit 282d472

Please sign in to comment.