ECMAScript Cookbook: Over 70 recipes to help you learn the new ECMAScript (ES6ES8) features and solve common JavaScript problems by Ross Harrison

ECMAScript Cookbook: Over 70 recipes to help you learn the new ECMAScript (ES6ES8) features and solve common JavaScript problems by Ross Harrison

Author:Ross Harrison
Language: eng
Format: epub
Tags: COM051260, COM060160, COM060080
Publisher: Packt Publishing
Published: 2018-03-29T06:45:31+00:00


export function main() { const array0 = (new Array(10000)).fill().map(Math.random); const array1 = (new Array(1000)).fill().map(Math.random); const array2 = (new Array(100)).fill().map(Math.random); }

Call sumOnWorker with each of the arrays, and log out the results:

export function main() { // ... sumOnWorker(array0).then((sum) => console.log('Array 0 sum:

%s', sum));

sumOnWorker(array1).then((sum) => console.log('Array 1 sum:

%s', sum));

sumOnWorker(array2).then((sum) => console.log('Array 2 sum:

%s', sum));; }

Create a worker.js file, assign the current context to a variable global, and assign a function to the onmessage event:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.