# JavaScript's global object is now "globalThis"

**URL:** <https://forum.kirupa.com/t/javascripts-global-object-is-now-globalthis/638917>\
**Category:** web dev\
**Created:** [November 8, 2018, 1:28am UTC](https://forum.kirupa.com/t/javascripts-global-object-is-now-globalthis/638917 "2018-11-08T01:28:44Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [November 8, 2018, 1:28am UTC](https://forum.kirupa.com/t/javascripts-global-object-is-now-globalthis/638917/1 "2018-11-08T01:28:44Z")

</div>

Just noticed the name change today. Too much breaking the web 🙄 by using just `global` so we’re left with `globalThis` (still stage 3 but almost there).

> **[tc39/proposal-global](https://github.com/tc39/proposal-global)**
>
> ECMAScript Proposal, specs, and reference implementation for \`global\` - tc39/proposal-global

My first impression on the naming…

![Related image](https://i.imgflip.com/6zigb.jpg)

---

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [November 8, 2018, 3:47am UTC](https://forum.kirupa.com/t/javascripts-global-object-is-now-globalthis/638917/2 "2018-11-08T03:47:02Z")

</div>

In what environment are you seeing `globalThis`? I’m on the latest Chrome Canary, and I don’t see it yet. Should check in Node?

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [November 8, 2018, 4:47am UTC](https://forum.kirupa.com/t/javascripts-global-object-is-now-globalthis/638917/3 "2018-11-08T04:47:14Z")

</div>

I see it in Canary

> Version 72.0.3604.0 (Official Build) canary (64-bit)

 ![image](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/2X/a/a41eb894d5c19d3e9f2d5d4cdb5182295b980637.png)

---

<div class="post-metadata">

**Author:** ![krilnon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/krilnon/32/34_2.png) [@krilnon](https://forum.kirupa.com/u/krilnon)\
**Post date:** [November 8, 2018, 6:24am UTC](https://forum.kirupa.com/t/javascripts-global-object-is-now-globalthis/638917/4 "2018-11-08T06:24:22Z")

</div>

My mind only remembers the safe/guaranteed way to get this object in AS3:

```auto
var global = function() { return function() { return this }() }()

```

---

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [November 9, 2018, 5:49pm UTC](https://forum.kirupa.com/t/javascripts-global-object-is-now-globalthis/638917/5 "2018-11-09T17:49:25Z")

</div>

I see it now! Turns out my Canary was out-of-date 🐛

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [November 10, 2018, 1:57pm UTC](https://forum.kirupa.com/t/javascripts-global-object-is-now-globalthis/638917/6 "2018-11-10T13:57:58Z")

</div>

Were both functions needed?

---

<div class="post-metadata">

**Author:** ![krilnon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/krilnon/32/34_2.png) [@krilnon](https://forum.kirupa.com/u/krilnon)\
**Post date:** [November 10, 2018, 9:21pm UTC](https://forum.kirupa.com/t/javascripts-global-object-is-now-globalthis/638917/7 "2018-11-10T21:21:13Z")

</div>

In some contexts, I think so. In particular, I think if you were contextually inside of a method, a single function would have its `this` bound to the relevant class instance.

And my habit of always spelling it that way came out of people asking questions an omitting the fact that the code in question was actually in that context. (Probably helped by the scoping rules for timeline code…)

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [November 10, 2018, 10:12pm UTC](https://forum.kirupa.com/t/javascripts-global-object-is-now-globalthis/638917/8 "2018-11-10T22:12:10Z")

</div>

`_level0` FTW!

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [October 5, 2019, 1:31am UTC](https://forum.kirupa.com/t/javascripts-global-object-is-now-globalthis/638917/9 "2019-10-05T01:31:54Z")

</div>

`globalThis` is now officially in stage 4 (as of the october meetings) and has been included in the current draft of the spec.

- [https://github.com/tc39/proposals/blob/master/finished-proposals.md](https://github.com/tc39/proposals/blob/master/finished-proposals.md)
- [https://tc39.es/ecma262/#sec-globalthis](https://tc39.es/ecma262/#sec-globalthis)
