Files
Lab4/8/app.js
MishaBagger b6c10cc93f MACHIN
2023-10-25 09:15:21 +03:00

33 lines
802 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function display(data, callback) {
// с помощью случайного числа определяем ошибку
var randInt = Math.random() * (10 - 1) + 1;
var err =
randInt > 5
? new Error(
'Ошибка выполнения. randInt больше 5'
)
: null;
setTimeout(function () {
callback(err, data);
}, 0);
}
function displaySync(callback) {
callback();
}
console.log('Начало работы программы');
setTimeout(function () {
console.log('timeout 500');
}, 500);
setTimeout(function () {
console.log('timeout 100');
}, 100);
displaySync(function () {
console.log('without timeout');
});
console.log('Завершение работы программы');