By default the runtime is hosted in a Web Worker.
Use self
or globalThis
to access the global scope instead. Those work in all environments, and window
only works specifically in the DOM and nowhere else.
Got it Ashley , I have another problem, I can't set / prototype a key into global scope.
Ex: globalThis.window["test"] = 123;
It will return error, test not defined, however in normal javascript it's work fine