DEV Community

loading...
Cover image for What is globalThis? ES2020 new features

What is globalThis? ES2020 new features

twostepdevelopers
I'm a software engineer,I've started teaching to students and doing master in computer science.
・1 min read

A new property added in es2020 called globalThis. It's cross-platform support to access to the global object in JavaScript. Accessing the global property in JavaScript has always posed some difficulty. This is because different platforms have different ways to access it.

such as :
Client side uses: windows,frames,this
web workers uses: self
node js uses: global

now all environment can use simple globalThis .
Also you can watch my video on this topic.
https://youtu.be/yn3J6KfMqBw

Discussion (0)