View command line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker compose up -d |
View main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function main() { | |
console.log(1) | |
setTimeout(()=>{ | |
console.log(2) | |
setTimeout(()=>{ | |
console.log(3) | |
}, 2000) | |
}, 1000) | |
} |
View main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function main() { | |
console.log(1) // ปริ้น 1 | |
delay(1000) // รอ 1 วินาที ถึงจะเรียกฟังชั่นบรรทัดที่ 4 | |
.then(()=> { | |
console.log(2) // ปริ้น 2 | |
return delay(2000) // รอ 2 วิ ค่อยเรียกบรรทัดที่ 8 | |
}) | |
.then(()=>{ | |
console.log(3) | |
}) |
View main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function main() { | |
console.log(1) | |
await delay(1000) | |
console.log(2) | |
await delay(2000) | |
console.log(3) | |
} | |
function delay(ms) { | |
return new Promise((resolve)=>{ |
View main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function main() { | |
const user = await promiseFindUser() | |
console.log('name: ', user.name) | |
} | |
function promiseFindUser() { | |
return new Promise((resolve)=>{ | |
setTimeout(()=>{ | |
const user = { | |
name: 'Thor' |
View main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setTimeout(function callMeBaby() { console.log(5) }, 1000) | |
function setTimeout(callback, ms) { | |
// รอ 1000 ms | |
callaback() | |
} |
View main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setTimeout(function callMeBaby() { | |
console.log(6) | |
}, 1000) |
View main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function waitingForPrint5() { | |
setTimeout(() => { | |
console.log(5) // รอ 1 วิค่อยปริ้น 5 อธิบายต่อข้างล่างนะครับ | |
}, 1000) | |
} | |
function main() { | |
waitingForPrint5() // เมื่อมันทำงานบรรทัดนี้ยังไม่เสร็จตามต้องการ | |
// ยังไม่ Print 5 แต่สั่งไปแล้วนะให้ปริ้น | |
// แต่มันบอกไปก่อนเลยเพื่อนไม่ต้องรอ |
View main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function main() { | |
console.log(1) // เมื่อทำบรรทัดนี้เสร็จ ได้ 1 ออกมาที่ console ถึงจะเริ่มทำบรรทัดต่อไป | |
console.log(2) | |
} | |
main() |
View main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const unused01 = (resolve) => { | |
resolve() | |
} |
NewerOlder