The global object is used in Node.js environments, but in browser environments the global object is window. So it's important to check the context of the execution before using the global object.
Proposed fix
In JavaScript, you can use the typeof process to check if your code is running in a Node.js environment or not. The process object is a global object that is only available in Node.js, so if typeof process returns "object", it means your code is running in a Node.js environment. If it returns "undefined", it means your code is running in a browser environment.
Additionally, the ?. operator is a new feature in javascript and it's not supported in all environments, so you should check if your environment supports it or use a polyfill. But this is beyond the scope of this pull request.
Problem
The
global
object is used in Node.js environments, but in browser environments the global object iswindow
. So it's important to check the context of the execution before using the global object.Proposed fix
In JavaScript, you can use the
typeof process
to check if your code is running in a Node.js environment or not. The process object is a global object that is only available in Node.js, so if typeof process returns "object", it means your code is running in a Node.js environment. If it returns "undefined", it means your code is running in a browser environment.Additionally, the ?. operator is a new feature in javascript and it's not supported in all environments, so you should check if your environment supports it or use a polyfill. But this is beyond the scope of this pull request.