function work() {
setTimeout(() => {
const start = Date.now();
for (let i = 0; i < 1000000000; i++) {}
const end = Date.now();
console.log(end - start + 'ms');
}, 0);
}
console.log('작업 시작!');
work();
console.log('다음 작업');
//작업 시작
//다음 작업
//20582ms
If you write setTimeout() that is running in background, result of work() is turning out last time.
function work(callback) {
setTimeout(() => {
const start = Date.now();
for (let i = 0; i < 1000000000; i++) {}
const end = Date.now();
console.log(end - start + 'ms');
callback();
}, 0);
}
console.log('작업 시작!');
work(() => {
console.log('작업이 끝났어요!')
});
console.log('다음 작업');
But second case result isn't same. result of callback() is last.
When I tried on my vest, it looked good; it almost fit, which is the most crucial factor for me.
https://golden-corral-menu-prices.info/