I\'m trying to pass an object to a web worker through the postMessage function. This object is a square that has a couple of functions to draw himself on a canvas and so
if you want to pass the object with methods you can stringify it and parse it at the receiving end.
postMessage(JSON.stringify(yourObject)
In the listener
this.worker.addEventListener('message', (event) => { const currentChunk = JSON.parse(event.data); });