???
JavaScript Promise? ??? ????? ??? ?????? ????? ???? ??.
??????? ??? Promise? ??? ???! Promise/A ??? ??? Promise? ??? ??? ????, ????, ????, ?? ??? ?? ? ?? ??? ???? ??? ?????.
?? ???? ???? ?? Promises/A ???? ?? ??? ?? ??? ??? ?????. ?? ?? ??? ??? ???? ?????. ??? ??? ??? ??? ????.
1. ??
1.1 'promise'? ? ??? ???? ??? ?? then ???? ?? ?? ?? ?????.
1.2 thenable'? then ???? ???? ?? ?? ?????.
1.3 '?'? ??? JavaScript ?(???? ??, Thenable ?? Promise ??)???.
1.4 '??'? throw ?? ???? ???? ????.
1.5 '??'? Promise? ??? ??? ???? ????.
2. ????
2.1 ?? ??
??? ??, ?? ?? ??? ? ?? ?? ? ???? ???.
2.1.1. ?? ?? ?? ??: ?
? ?? ?? ?? ??? ??? ? ????.
2.1.2. ???? ??: ?
? ?? ??? ???? ? ???.
? ?? ??? ?? ?????? ? ???.
2.1.3. ???? ??: ?
? ?? ??? ???? ? ???.
? ?? ? ?? ??? ??? ???.
2.2 then ???
Promise? ?? ?? ?? ??? ??? ????? ?? then ???? ???? ???.
Promise? then ???? ? ?? ??? ????:
promise.then(onFulfilled, onRejected);
2.2.1. onFulfilled ? onRejected? ?? ??? ?????: ?
? onFulfilled? ??? ??? ???? ???.
? onRejected? ??? ?? ?? ???? ???.
2.2.2. onFulfilled? ??? ??: ?
? Promise ?? ? ?? ??? ???? Promise? ??? ?? ???? ???.
? ??? ???? ??? ???? ? ???.
? ? ? ?? ???? ? ???.
2.2.3. onRejected? ??? ?? ?
? Promise? ??? ?? ???? ?? Promise? ??? ? ?? ??? ???? ???? ???.
? ??? ???? ?? ???? ? ???.
? ? ? ?? ???? ? ???.
2.2.4. ?? ???? ??? ??? ??? ??? ??? onFulfilled ?? onRejected? ???? ? ???. ?
2.2.5. onFulfilled ? onRejected? ??? ????? ???(?, ? ?? ??). ?
2.2.6. ?? ?? ??? Promise? ?? ?? ? ??? ? ????. ?
? ??? ???? ?? ?? onFulfilled ??? ?? ?? ???? ????? ???.
? ??? ???? ?? ?? ?? onRejected ??? ?? ?? ???? ????? ???.
2.2.7. ?? ?? ??? ???? ???. ?
promise.then(onFulfilled, onRejected);
? onFulfilled ?? onRejected? x ?? ???? ?? ?? ?? ?? [[Resolve]](promise2, x)? ?????. ?
? onFulfilled ?? onRejected?? ?? e? ???? promise2? e? ??? ????? ???. ?
? onFulfilled? ??? ??? promise1? ??? ?? promise2? promise1? ??? ??? ????? ???. ?
? onRejected? ??? ??? promise1? ??? ?? promise2? promise1? ?? ??? ????? ???. ?
??
JavaScript Promise? Promise? ??? ? ?? ???? ??? ??? ??? ?????.
promise2 = promise1.then(onFulfilled, onRejected);
new Promise(excecutor);
?? Promise/A ??? Promise? ??, ?? ?? ???? ??? ??? ????. ??? ???? ?? ????. ??? Promise ??? ?? ???? ??? JavaScript? ??? API? ????? ???. Promise ???? ? ?? ??? ??? ????.
const promise = new Promise((resolve, reject) => { // Runs some async or sync tasks });
?? 2.1(?? ??)?? ??? ??, ?? ?? ??? ? ?? ?? ? ??? ??? ??? ???? ????. ?? ? ???? ?? ?? ????? ?????.
Promise? ????? ???? Promise? ?? ??? ?????? ? ???. ??? ??? ?? ?? Promise? ?? ???? ???? ???.
class YourPromise { constructor(executor) { this.state = 'pending'; this.value = undefined; this.reason = undefined; const resolve = value => { if (this.state === 'pending') { this.state = 'fulfilled'; this.value = value; } }; const reject = reason => { if (this.state === 'pending') { this.state = 'rejected'; this.reason = reason; } }; try { executor(resolve, reject); // The executor function being called immediately } catch (error) { reject(error); } } }
????? ?? ??? ?? ???? ?? ?? ?? ??? ????? ????? ??? ??? ??? ????? ???.
const resolve = value => { if (this.state === 'pending') { this.state = 'fulfilled'; this.value = value; } }; const reject = reason => { if (this.state === 'pending') { this.state = 'rejected'; this.reason = reason; } };
??? ??? promise? ??????? ?? ????? ??? ??? ??? ?????.
this.state = 'pending';
YourPromise ???? ? ?? ??? ???? ???????.
Promise/A ??? ?? ?? ?? ??? then() ???? ???? ? ??? ???. ? ???? ???? Promise? ?? ?? ?? ??? ??? ???? ? ????. ??? ???????.
?? 2.2(then ???)??? Promise? ? ?? ??? ???? then() ???? ??? ??? ?????.
try { executor(resolve, reject); } catch (error) { reject(error); }
onFulfilled ? onRejected? ?? ??? ????? ??? ?? ????? ??, ??? ?? ??? ??? ??? ? ?? ??? ???? ???.
class YourPromise { constructor(executor) { // Implementation } then(onFulfilled, onRejected) { // Implementation } }
?? ??? ????? ???? ?? ????? ? ??, ? ? ?? ???? ? ???. onFulfilled ? onRejected? ?? ?? ????? ??? ?? ?? ???? ???.
?? 2.2, 2.2.6, 2.2.7? ?? Promise?? then() ???? ??? ?? then() ???? ?? ? ??? ? ??? ??? ???? ??? ?? ? ? ????. ??:
promise.then(onFulfilled, onRejected);
???? ?? ?? ??? ???? ??? ??? ????. ??? ??? ???? Promise ??? ?????.
promise2 = promise1.then(onFulfilled, onRejected);
Executor ?? ??? ??? ???? onFulfilled ??? ???? ?? ??? ?????. ????? ??? ???? onRejected ??? ???? ?? ??? ?? ?????.
?? ??? Promise? ?? ?? ??? ?? onFulfilled ? onRejected ??? ??? ???? ??????. ??? ?? ??? ????? ???? ?????.
new Promise(excecutor);
?????. ??? then() ???? ???? Promise ???? ? ?? ?????.
const promise = new Promise((resolve, reject) => { // Runs some async or sync tasks });
????? ??? ???? ?? ???? onFulfilledCallbacks ? onRejectedCallbacks?? ? ??? ?????. ??? ???? Promise? ?? ?? ?? then() ??? ?? ???? ???? Promise? ????? ??? ? ?????.
Promise ???? ???? ???.
class YourPromise { constructor(executor) { this.state = 'pending'; this.value = undefined; this.reason = undefined; const resolve = value => { if (this.state === 'pending') { this.state = 'fulfilled'; this.value = value; } }; const reject = reason => { if (this.state === 'pending') { this.state = 'rejected'; this.reason = reason; } }; try { executor(resolve, reject); // The executor function being called immediately } catch (error) { reject(error); } } }
??? ?? ????? ???.
const resolve = value => { if (this.state === 'pending') { this.state = 'fulfilled'; this.value = value; } }; const reject = reason => { if (this.state === 'pending') { this.state = 'rejected'; this.reason = reason; } };
??, ?? ???? ????:
this.state = 'pending';
??? ?? ? ????:
try { executor(resolve, reject); } catch (error) { reject(error); }
??:
class YourPromise { constructor(executor) { // Implementation } then(onFulfilled, onRejected) { // Implementation } }
??? ??? then()? ??? ? YourPromise ????? ?? ????? ??? ?? then() ???? ??? ???? ??? ????. ?? ?? ??? ?? ?? ?? ?? then() ???? ?? ??? ?? ???? ?? ???? ???? ???? ????. ??? ?? ?? ?? ??? ?????. ?? ??????:
? ??? '?? ??'??? ??? ?? ?????.
? promise.then()? ???? ??? ?? ??????? onFulfilled ??? ?? ???? ?? ???? ???? ?? ?? ?????.
??? ?? 2.2.4? ?????. ? ??? Promise? ?? ????? ??? ???? then() ??(onFulfilled ?? onRejected)? ?????? ????? ?????. ?, ?? ?? ??? ??? ???? ??? ??(?: ??? ?? ?? ???? ?? ???)? ??? ??? ??? ????? ? ???.
? ??? ? ??????
? ??? Promise/A ???? ?? ??? ?? ? ?????. ??? ???? ?????.
? Promise? ?? ?????? ?? then() ??? ??? ??? ?? ??? ???? ????.
? ? ??? setTimeout ?? process.nextTick? ?? JavaScript? ?? ??? API ??? ?????.
??? ?? ??? ? ????
?? setTimeout ?? setImmediate? ?? ??? ?? ?????? queueMicrotask ?? process.nextTick? ?? ???? ?? ????? ???? ??? ? ????. ???? ???? ??? ?? ?? ?? ??? ????? ??? ?? JavaScript ?? ????? ??? ?? ???? ?????.
? ??? ????? ??? ?? ????? ??? ???? ?? ??(onFulfilled ?? onRejected)? queueMicrotask? ???? ?????? ????? ?? ???. ??? ??? ??? ????.
promise.then(onFulfilled, onRejected);
?? ?? ??? ??? ?? ?????. ??? ?? ??? ?????.
promise2 = promise1.then(onFulfilled, onRejected);
?????.
?? then()? ??? ??? ???? ?? ???? ?? ????? ???? ??? ??? ?????? ???? ???? ???. JavaScript? ???? ??? ??? ????? ? ??? ??? ???? ?? ??????.
??? ?????? ? ????? ?? Promises/A ??? ??? ????? ? ?? ???? ?? ??? ??? ??? ? ? ????.
???? ????? ???? ????? ????! ??? ??????.
???:
LinkedIn, Medium, Github
? ??? JavaScript? ??? Promise ???? ?? ?????. ??? ??? 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)

??? ??











Java ? JavaScript? ?? ?? ????? ??? ?? ?? ?? ???? ????? ?????. Java? ??? ? ??? ?????? ??? ???? JavaScript? ?? ? ??? ??? ?????.

JavaScript?? ??? ??? ?? ? ? ?? ??? ???????. 1. ?? ??? ??? ???? ?? ??? ????. ISO ?? ???? ???? ???? ???? ?? ????. 2. ?? ??? ?? ???? ??? ?? ???? ??? ? ??? ? ?? 0?? ????? ?? ??????. 3. ?? ?? ???? ???? ???? ?? ?????? ??? ? ????. 4. Luxon? ?? ???? ???? ?????? ???? ?? ????. ??? ?? ???? ????? ???? ??? ????? ?? ? ????.

TAGGSATTHEBOTTOMOFABLOGPOSTORWEBPAGESERVESPRACTICALPURSEO, USEREXPERIENCE, andDESIGN.1.ITHELPSWITHEOBYOWNSESPORENGENSTOESTOCESKESKERKESKERKERKERDER-RELEVANTTAGSWITHOUTHINGTEMAINCONTENT.2.ITIMPROVESEREXPERKEEPINGTOPONTEFOCUSOFOFOFOCUSOFOFOFOCUCUSONTHEATECLL

JavaScriptIspreferredforwebDevelopment, whithjavaisbetterforlarge-scalebackendsystemsandandandoidapps.1) javascriptexcelsincreatinginteractivewebexperiences withitsdynatureanddommanipulation.2) javaoffersstrongtypingandobject-Orientededededededededededededededededdec

??? ?? ? ??? DOM?? ??? ??? ? ?????. ??? ?? ????? ?? ??????, ??? ?? ???? ?? ????????. 1. ??? ??? addeventListener? usecapture ?? ??? true? ???? ?????. 2. ??? ??? ?? ???? usecapture? ???? ????? ?????. 3. ??? ??? ??? ??? ???? ? ??? ? ????. 4. ??? ?? ?? ?? ??? ?? ??? ??????? ??? ???? ?????. 5. ??? ?? ?? ?? ??? ?? ???? ?? ???? ? ??? ? ????. ? ? ??? ???? ???? JavaScript? ??? ??? ??? ????? ???? ???? ??? ??????.

javascriptassevenfundamentalDatatatypes : ??, ???, ??, unull, ??, ? symbol.1) ?? seAdouble-precisionformat, ??? forwidevaluerangesbutbecautiouswithfatingfointarithmetic.2) stringsareimmutable, useefficientconcatenationmethendsf

JavaScript ?? ????? ??????? ??? ?? ??? ??? ????? ?? ??? ????. ????? ??? ?????. 1. ?? ?? (CodesPlitting) ??, ?? ??? React.lazy ()? ?? ?? ?? ?? ??? ????? ??? ???? ? ?? ????? ??? ?? ??? ???????. 2. ???? ?? ?? (???)? ????, ES6 ?? ????? ???? "Dead Code"? ???? ?? ? ????? ?? ??? ??? ? ???????. 3. ?? ??? ???? ???? GZIP/BROTLI ? TERSER? JS? ???? ??? ????? ???? ?? ???? ??? ? ? ??????. 4. ??? ???? ???? day.js ? fetch? ?? ?? ?????? ??????.

ES ??? CommonJS? ?? ???? ?? ?? ? ?? ???????. 1. Commonjs? ????????? Node.js ?? ? ??? ?????. 2.ES ??? ???????? ????? ?? ???? ??? ?????. 3. ??, ES ??? ?? ??/????? ???? ??? ??? ?????? CommonJS? Quiew/Module.exports? ???? ???? ???? ?? ? ? ????. 4. Commonjs? Express? ?? ???? Node.js ? ?????? ?? ???? ?? ???? ?? ES ??? ?? ??? ?? ??? ?? ? Node.jsv14? ?????. 5. ?? ? ? ??? ?? ??? ??? ? ????.
