Contact emails

math...@chromium.org

Spec

https://tc39.github.io/proposal-global/

Summary

A Stage 3 proposal introduces globalThis, enabling a universal mechanism to
access the global object even in strict functions or modules, regardless of
the platform.

Motivation

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. 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
using Function('return
this')(), but that form is incompatible with some CSP settings, such as
within Chrome Apps.

Interoperability and compatibility risk

An earlier version of this proposal had a different name: global. Sadly,
this name was found to be not Web-compatible when Firefox shipped it
<https://github.com/tc39/proposal-global/issues/20>. After collaborating
with other browsers vendors and looking at data on real-world use of
JavaScript identifiers on the web, we believe the new name to be
Web-compatible.

Is this feature fully tested?

Yes. In addition to V8's own tests (v8/test/mjsunit/harmony/global*.js),
Test262 includes tests for this feature
<https://github.com/tc39/test262/search?q=%22features%3A+%5BglobalThis%5D%22>
.

Tracking bug

https://bugs.chromium.org/p/v8/issues/detail?id=5537

Link to entry on the Chrome Platform Status dashboard

https://www.chromestatus.com/feature/6571514765770752

Requesting approval to ship?

Yes. Note that since this is a V8/JS feature, this post is just an FYI to
blink-dev — no signoff from Blink API owners is required.

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to