JavaScript? ? ??
Web Worker? ? ???? ????? ????? ????? ??? ? ?? ??? ??? ???? ?? ???? ???? ??? ?? ??? ??? ? ??? ????. ? ??? ? ??????? ?? ???? ?? ?????.
? ??? ??????
Web Workers? ?? ???? ??? ????? ???? JavaScript ???????. ?? ?? ??? ?????? ???? ?? ??? ??, ??? ?? ?? ??? ????? ?? ??? ??? ? ????.
Web Worker? ?? ??
- ?????: ?? ???? ??? ??????? ?????.
- ???? UI: UI ??? ???? ??? ??? ?????.
- ???: ???? ?? ??? ????? ???? DOM ??? ???? ????.
- ???? ?? ??: ?? ????? ????? postMessage ? onmessage? ???? ?????.
? ?? ??
1. ??????
?? ???? Worker ???? ???? ??? ?????.
// main.js const worker = new Worker("worker.js"); worker.postMessage("Hello, Worker!"); // Sending a message to the worker worker.onmessage = (event) => { console.log("Message from worker:", event.data); };
2. ??? ????
???? onmessage ???? ???? ???? ?????.
// worker.js onmessage = (event) => { console.log("Message from main thread:", event.data); const result = event.data.toUpperCase(); // Example computation postMessage(result); // Sending a message back to the main thread };
?? ?? ? ??
?? ??? ??:
- Worker(postMessage): ????? ???? ????.
- Worker.terminate(): ???? ?? ???????.
??? ??:
- self.postMessage(): ???? ?? ???? ?? ????.
?? ???:
- onmessage: ???? ???? ??????.
- onerror: ???? ??? ?????.
?: ??? ?? ??
// main.js const worker = new Worker("worker.js"); worker.postMessage(1000000); // Sending a number for processing worker.onmessage = (event) => { console.log("Sum calculated by worker:", event.data); }; worker.onerror = (error) => { console.error("Worker error:", error.message); }; // worker.js onmessage = (event) => { const num = event.data; let sum = 0; for (let i = 1; i <= num; i++) { sum += i; } postMessage(sum); // Return the result to the main thread };
? ??? ??
-
???? ??:
- ?? ????? ?? ?????.
- ?? ?? ???? ???? ?????.
-
?? ???:
- ?? ?????? ??? ? ????.
- SharedWorker? ???? ???????.
// main.js const worker = new Worker("worker.js"); worker.postMessage("Hello, Worker!"); // Sending a message to the worker worker.onmessage = (event) => { console.log("Message from worker:", event.data); };
-
??? ???:
- ??? ???? ???? ??? ????? ? ?????.
- Web Workers? ???? ??? ?? ?? ?? ??
? ???? ??
- DOM ??? ??: ???? DOM? ?? ?? ??? ? ????.
- ??? API: XMLHttpRequest ?? ????? ?? ?? API? ?????.
- ??? ??: ???? ???? ???? ??? ??? ?? ???? ?????.
- ????: ???? ?? ?? ???? ???? ??? ? ????.
? ??? ???? ?? ??
- ???? ?? ??(?: ??, ??? ??)
- ??????? ??? ??? ??? ???? ?????.
- ?? ??? ??? ?? ??? ??????.
- SPA(?? ??? ??????)? ???? ?????.
Web Worker ?? ?? ??
- ??? ?? ??: ?? ??? ?? ?? ??? ???? ???? ?????.
- ??? ?? ??: ???? ??? ??? ???? ???? ????? ?????. ????? ??? ??? ??? ????.
- ?? ??: ?? onerror ???? ???? ??? ??? ?????.
- ??? ??: ???? ? ?? ???? ?? ? ???.terminate()? ???? ???? ?????.
??
Web Workers? ?? JavaScript ???? ?? ?? ???, ?????? ???? ? ?? ??? ? ??? ??? ??? ?????. ?? ??? ?? ??? ???? ?????? ?? ????? ??? ? ????.
?????. ?? Abhay Singh Kathayat???!
?? ?????? ??? ?? ??? ?? ?? ??? ?? ??? ??????. ?? ????? ?? ???? ??? ???? ??????? ???? ?? ??? ????? ?? ? ?????? ???? ?????.
? ???? ???? kaashshorts28@gmail.com?? ???? ?????.
? ??? JavaScript? ? ??? ?? ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

JavaScript? ??? ?? ????? ??? ?? ??? ??? ?? ?? ?? ????? ?? ???? ???? ?????. ??? ?? ???? ?? ??? ?? ??? ???? ???? ?? ?? ???? ???? ?????. ?? ??, ??? ? ?? ???? ??? (? : ??? null? ??) ?? ??? ????? ??????. ??? ??? ???? ??? ??? ????. closure?? ?? ??? ?? ??; ? ??? ??? ?? ?? ???? ?? ???? ????. V8 ??? ?? ???, ?? ??, ??/?? ???? ?? ??? ?? ??? ??? ????? ?? ??? ?? ??? ????. ?? ?? ???? ??? ??? ??? ??? ???? ????? ?? ?? ???? ?? ???????.

Node.js?? HTTP ??? ???? ? ?? ???? ??? ????. 1. ?? ????? ????? ??? ??? ? ?? ????? ?? ?? ? https.get () ??? ?? ??? ??? ? ?? ????? ?? ??? ?????. 2.axios? ??? ???? ? ?? ??????. ??? ??? ??? ??? ??? ??? ???/???, ?? JSON ??, ???? ?? ?????. ??? ?? ??? ????? ?? ????. 3. ?? ??? ??? ??? ??? ???? ???? ??? ??? ???? ?????.

JavaScript ??? ??? ?? ?? ? ?? ???? ????. ?? ???? ???, ??, ??, ?, ???? ?? ? ??? ?????. ?? ????? ?? ?? ? ? ??? ????? ?? ??? ??? ????. ??, ?? ? ??? ?? ?? ??? ??? ??? ???? ??? ??? ???? ??? ?? ??? ????. ?? ? ????? ??? ???? ? ??? ? ??? TypeofNull? ??? ?????? ??? ? ????. ? ? ?? ??? ???? ?????? ????? ???? ??? ???? ? ??? ? ? ????.

?????, JavaScript ???! ?? ? JavaScript ??? ?? ?? ?????! ?? ?? ??? ??? ??? ? ????. Deno?? Oracle? ?? ??, ??? JavaScript ?? ??? ????, Google Chrome ???? ? ??? ??? ???? ?????. ?????! Deno Oracle? "JavaScript"??? ????? Oracle? ?? ??? ??? ??????. Node.js? Deno? ??? ? Ryan Dahl? ??? ?????? ???? ????? JavaScript? ??? ???? Oracle? ????? ???? ?????.

?? JavaScript ??? ??? ??? ?????? ?? ??? ?? ?? ??? ?? ???? ????. 1. ??? ???? ???? ?? ??? ?? ? ? ???? ??? ??? ?? ? ?? ????? ?????. 2. Angular? ?????? ??? ?? ???? ? ?? ?? ??? ??? ??? ???? ?????. 3. VUE? ???? ?? ??? ???? ?? ?? ??? ?????. ?? ?? ?? ??, ? ??, ???? ???? ? SSR? ???? ??? ??? ??? ???? ? ??? ?????. ???, ??? ??? ??? ????? ????. ??? ??? ??? ??? ?? ????.

iife (?? invokedfunctionexpression)? ?? ??? ???? ?? ????? ??? ???? ?? ??? ????? ?? ??? ? ?????. ??? ?? ?? ??? ???? ? ?? ??? ??? ?? (function () {/code/}) ();. ?? ???? ??? ?????. 1. ?? ??? ??? ?? ???? ?? ??? ??? ?????. 2. ?? ??? ??? ???? ?? ?? ??? ????. 3. ?? ?? ??? ????? ?? ???? ???????? ?? ? ??. ???? ?? ???? ?? ??? ES6 ??? ??? ??? ?? ? ??? ????? ??? ? ???? ???????.

??? JavaScript?? ??? ??? ?????? ?? ???????. ?? ??, ?? ?? ? ??? ??? ?? ????? ????? ?????. 1. ?? ??? ??? ????? ???? ??. ()? ?? ??? ??? ?????. ?. ()? ?? ??? ?? ??? ??? ?? ? ? ????. 2. ?? ??? .catch ()? ???? ?? ??? ??? ?? ??? ??????, ??? ???? ???? ????? ??? ? ????. 3. Promise.all ()? ?? ????? (?? ?? ?? ? ??????? ??), Promise.Race () (? ?? ??? ?? ?) ? Promise.AllSettled () (?? ??? ???? ??)

Cacheapi? ?????? ?? ???? ??? ???? ???, ?? ??? ??? ?? ???? ? ??? ?? ? ???? ??? ??????. 1. ???? ????, ??? ??, ?? ?? ?? ???? ???? ??? ? ????. 2. ??? ?? ?? ??? ?? ? ? ????. 3. ?? ?? ?? ?? ?? ??? ??? ?? ?????. 4. ??? ???? ?? ?? ???? ?? ?? ?? ?? ?? ???? ?? ?? ??? ??? ? ????. 5. ?? ???? ??, ??? ??? ? ??? ??, ?? ??? ? ?? ???? ???? ???? ? ?? ?????. 6.?? ??? ?? ?? ?? ??, ???? ?? ? HTTP ?? ????? ?????? ???????.
