JavaScript ??? ??? ?? ??? ? ?????? ??? ?????. ?? ??? ??(?: addEventListener
)? ????? ?? ??? ?? ???? ??? ?????, ??? ??? ?? ??? ????, ?? ???? ?? ??? ??? ? ????.
? ????? JavaScript? ?? ??? ?? ??? ???? ??? ?? ??? ???? ? ?? ?? ?? ?????.
-
????
??????? ??????
??? ??? ?? ??? ???? ?? ??? ???? ?? ?? ??? ?? ???? ???? ?? ?????. ? ??? ???? ??? ? DOM? ???? ???? ??? ?? ?????.
?:
document.getElementById("parent").addEventListener("click", function(event) { if (event.target && event.target.matches(".child")) { console.log("點擊了子元素:", event.target.textContent); } });
??? ??? ???? ??? ??????
- ??? ??? ?? ??? ??? ??????.
- ???? ??? ??? ??? ??????.
-
??? ? ??? ??
??????
- ????? ?? ??? ??? ?? ? ? ????? ???.
- ?? ????? ??? ?? ?? ??? ??? ??? ?? ??? ?????.
?:
??
function throttle(func, limit) { let lastCall = 0; return function(...args) { const now = Date.now(); if (now - lastCall >= limit) { lastCall = now; func.apply(this, args); } }; } window.addEventListener( "resize", throttle(() => { console.log("窗口大小已調(diào)整!"); }, 200) );
??? ??
function debounce(func, delay) { let timer; return function(...args) { clearTimeout(timer); timer = setTimeout(() => func.apply(this, args), delay); }; } const searchInput = document.getElementById("search"); searchInput.addEventListener( "input", debounce(() => { console.log("輸入事件觸發(fā)!"); }, 300) );
? ??????
- ?? ?? ???? ???? ?? ??? ?? ??? ?? ???? ?? ??? ?? ??? ?????.
-
?? ??? ???
??????
??? ?? ??? ???? ???? ???? ???? ??? ?? ?? ???? ??, ?? ? ?? ? ????.
const eventEmitter = { events: {}, on(event, listener) { if (!this.events[event]) this.events[event] = []; this.events[event].push(listener); }, emit(event, data) { if (this.events[event]) { this.events[event].forEach((listener) => listener(data)); } }, }; eventEmitter.on("dataReceived", (data) => { console.log("收到數(shù)據(jù):", data); }); eventEmitter.emit("dataReceived", { id: 1, message: "Hello!" });
? ??????
- ??? ??? ? ?? ?? ??.
- ??????? ?? ?? ?? ??????? ?????.
-
??? ??? ??
??? ??? ??? ??????
? ?? ???? ?? ??? ???? ??? ??? ????. ?? JavaScript? ? ??? ???? ??? ??? ?????.
?
const button = document.getElementById("myButton"); button.addEventListener( "click", () => { console.log("按鈕被點擊!"); }, { once: true } );
? ??????
- ??? ???? ??? ??????.
- ???? ???? ???? ??? ??? ?????.
-
??? ??? ??
??? ??? ?????
??? ??? ???? ???? ????? ???? ?? ?? ???? ???? ??? ?????.
?
function composeHandlers(...handlers) { return function(event) { handlers.forEach((handler) => handler(event)); }; } function logClick(event) { console.log("點擊:", event.target); } function changeBackground(event) { event.target.style.backgroundColor = "yellow"; } document.getElementById("myElement").addEventListener( "click", composeHandlers(logClick, changeBackground) );
? ??????
- ???? ?? ??? ???? ?????.
- ???? ?? ??? ??? ??? ?????.
-
?? ? ???
??????
JavaScript ??? ??? ? ??? ????.
- ?? ??: ???? ?? ???? ?? ??? ????.
- ??? ??: ???? ?? ???? ?? ??? ?? ????.
?
document.getElementById("parent").addEventListener("click", function(event) { if (event.target && event.target.matches(".child")) { console.log("點擊了子元素:", event.target.textContent); } });
? ??????
- ??? ?? ??? ???? ?????.
-
?? ?? ?? ? ?? ??
??????
preventDefault()
?? ???? ??(?: ?? ??)? ?????.stopPropagation()
???? ?? ????? ???? ?? ?????.
?
function throttle(func, limit) { let lastCall = 0; return function(...args) { const now = Date.now(); if (now - lastCall >= limit) { lastCall = now; func.apply(this, args); } }; } window.addEventListener( "resize", throttle(() => { console.log("窗口大小已調(diào)整!"); }, 200) );
? ??????
- ??? ??? ?? ???? ??? ? ????.
??
?? ??? ?? ??? ????? ????? ?? ??? ?? JavaScript ??????? ???? ? ??????. ??? ??, ??, ??? ?? ???, ?? ?? ?? ??? ??? ??? ?? ??? ?? ??? ? ????.
? ??? 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)

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

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

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

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

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

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

.map (), .filter () ? .reduce ()? ?? JavaScript ?? ?? ???? ??? ??? ??? ? ? ????. 1) .map ()? ??? ??? ??? ???? ? ??? ???? ? ?????. 2) .filter ()? ???? ??? ????? ? ?????. 3) .reduce ()? ???? ?? ??? ???? ? ?????. ???? ??? ????? ??? ?? ?? ??? ?????.

JavaScript? ??? ??? ?? ??, ? ? ? ?? ???? ???? ??? ??? ?????. 1. ?? ??? ?? ??? ???? ??? ??? ??? ??? ?? WebAPI? ?????. 2. WebAPI? ??????? ??? ?? ? ? ??? ?? ??? (??? ?? ?? ???? ??)? ????. 3. ??? ??? ?? ??? ?? ??? ?????. ?? ??? ??? ????? ??? ??? ?? ? ???? ?????. 4. ???? ?? (? : Promise. 5. ??? ??? ???? ?? ???? ???? ?? ?? ?? ??? ????? ? ??????.
