Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 11 JavaScript can't find variable `globalThis`

Is there a chance that JavaScript globalThis is not supported to be used with an iOS 11, or earlier versions?

Is there any solution to the globalThis, since now, I get an error for ReferenceError: main.chunk.js Can't find variable: globalThis?

like image 373
Shared User Avatar asked May 09 '26 17:05

Shared User


1 Answers

According to the MDN page on globalThis, iOS Safari support is version 12.2 or later.

For earlier versions, you will need a polyfill.

Or you could insert this code at the global context:

if (typeof globalThis === 'undefined') {
  var globalThis = Function('return this')();
}
like image 184
terrymorse Avatar answered May 11 '26 06:05

terrymorse