Transferring (not copying) data through postMessage

It is possible to actually just transfer large amounts of data using the postMessage function. What does that mean, and how it is different from what we've been doing so far with postMessage?

Well, the actual syntax of postMessage is: postMessage(aMessage, transferList).

What this means is, whatever you pass as transferList is apparently lost in the worker that sent it. You actually gave the other script the authority to own that data. You transferred the ownership of that data to that other script. Remember, this is different from what used to usually happen (that is, you can still access the object in the same script that sent it to the web worker/main script) because in this case, the data ...

Get Learn ECMAScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.