Part 31 | JavaScript Tutorial | Callbacks | setInterval and setTimeout in JavaScript | Event Loopin смотреть онлайн
1. Callback functions:-
---------------------
- Callback function is a function that is passed as an argument to another function and is executed when that function finishes its execution.
- The purpose of a callback function is to provide a way for a function to asynchronously return a result or execute some code after it has completed.
- In the below example, callBackFunc is function.
function sumValue(x, y, callBackFunc){
//Call the server to get the data from server.
let sum = x + y;
//Once data is received,invoke call back function.
callBackFunc(sum);
}
function printFunc(value) {
console.log(value);
}
1. setTimeout(function, milliseconds)
- If we want to execute any code only one time but after specifying the particular time, then we can use the setTimeout method.
2. setInterval(function, milliseconds)
- If we want to execute any code multiple times based on time interval then we can use the setTimeout method.
3. clearTimeout()
4. clearInterval()
Event looping in JS:-
-------------------
JavaScript is a single-threaded language, which means that it can only execute one piece of code at a time. However, it also has a built-in mechanism for handling asynchronous operations, known as the event loop.
The event loop is a continuously running loop that checks for new events in the event queue and processes them one by one. When an asynchronous operation is initiated, such as a setTimeout or a network request, it is added to the event queue and the event loop continues to run. When the operation is completed, a callback function is added to the event queue to be executed in the future.
console.log("start");
console.log("end");
Note that even though the setTimeout function was called with a delay of 0 milliseconds, it still waited until the main thread was finished before executing the callback. This is because it is an asynchronous operation that is queued up by the event loop.
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Part 31 | JavaScript Tutorial | Callbacks | setInterval and setTimeout in JavaScript | Event Loopin» бесплатно и без регистрации, вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.