How can we write window[funcName]()
in web-worker JS?
how access to function declared in top context of script ?
Inside a WebWorker
you can use self to reference to the global scope (you could also use this
(when it points to the global scope, exactly like it works for window
):
// worker.js
function foo() {
console.log("hello worker");
}
self['foo']()