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)