相关疑难解决方法(0)

Javascript中的globalThis是什么?理想的用例是什么?

Recently I have come across about globalThis in Javascript. I am not sure how it is going to behave if it is called from a function. Every time it is returning the window object. if that is the case, then why don't we directly use the window object. What is necessary of using globalThis?

If I call the from a function, then it is returning window object Example:

(function test(){
    console.log(globalThis); // returns window
})();


var obj = { …
Run Code Online (Sandbox Code Playgroud)

javascript ecmascript-6

2
推荐指数
1
解决办法
227
查看次数

标签 统计

ecmascript-6 ×1

javascript ×1