Search code examples
javascriptweb-worker

Is this a way to pass full objects between web worker threads?


I've read 2.7.6 Safe passing of structured data several times and I still am not understanding exactly what this means. Is this a way to pass a complete object, including retaining its prototype, between web worker threads (or in our case between the main and a worker thread)?

If so, that would avoid the issues trying to rebuild the prototype in each object passed.


Solution

  • And the answer is - copy constructors. We did performance testing of copy constructors vs setting the prototype and copy constructors were faster. A little faster in Chrome & Opera, worlds faster in IE and Firefox.

    enter image description here