For Business
Login
Home
Assessments
Mytat Certificates
Community
Courses
Premium Courses
jobs
Practice
Upskilling
Projects
Help
Run ยป
// Create a new worker var worker = new Worker("worker.js"); // Send message to worker worker.postMessage("Message to worker"); // Receive message from worker worker.onmessage = function(event) { console.log("Message from worker: " + event.data); }; // Terminate worker worker.terminate(); Example: worker.js: javascript Copy code // Worker code self.onmessage = function(event) { var message = event.data; console.log("Message received in worker: " + message); var result = "Processed: " + message.toUpperCase(); self.postMessage(result); }; html Copy code
Web Workers Example
Start Worker