Задачка с последнего собеса подписчика на позицию middle backend node.js🧐
В каком порядке будет вывод?
(async () => {
const testFunction = async function() {
this.traceId = Math.random() // 0.1
console.log('start', this.traceId); //
await new Promise(r => setTimeout(r))(r => setTimeout(r))
console.log('finish', this.traceId);
}
testFunction();
testFunction();
testFunction();
})()Правильный ответ 🤨:
// start 0.1
// start 0.2
// start 0.3
// finish 0.3
// finish 0.3
// finish 0.3
Присоединяйтесь к нашему общему чату и Discord серверу :)