Telegram Group & Telegram Channel
🖥 Задачи по Event Loop с собеседований

Задача №1

setTimeout(() => {
console.log('setTimeout')
})

const promise = new Promise((resolve, reject) => {
console.log(1);
setTimeout(() => {
console.log("timerStart");
resolve("success");
console.log("timerEnd");
}, 0);

Promise.resolve().then(() => {
console.log('resolve')
})
console.log(2);
});

promise.then((res) => {
console.log(res);
});

console.log(4);


Задача №2
setTimeout(function timeout() {
console.log('Таймаут 1');
}, 0);

let p = new Promise(function(resolve, reject) {
console.log('Создание промиса');

setTimeout(function timeout() {
console.log('Таймаут 2');
}, 0);

resolve();
});

p.then(function(){
console.log('Обработка промиса');
});

console.log('Конец скрипта');


Задача №3

const myPromise = (delay) => new Promise((res, rej) => { setTimeout(res, delay) })

setTimeout(() => console.log('in setTimeout1'), 1000);

myPromise(1000).then(res => console.log('in Promise 1'));

setTimeout(() => console.log('in setTimeout2'), 100);

myPromise(2000).then(res => console.log('in Promise 2'));

setTimeout(() => console.log('in setTimeout3'), 2000);

myPromise(1000).then(res => console.log('in Promise 3'));

setTimeout(() => console.log('in setTimeout4'), 1000);

myPromise(5000).then(res => console.log('in Promise '));


Задача №4

console.log(1);

setTimeout(() => console.log(2));

Promise.resolve().then(() => console.log(3));

Promise.resolve().then(() => setTimeout(() => console.log(4)));

Promise.resolve().then(() => console.log(5));

setTimeout(() => Promise.resolve().then(() => console.log(6)));

console.log(7);


Задача №5

console.log('start');

const promise1 = Promise.resolve().then(() => {
console.log('promise1');
const timer1 = setTimeout(() => {
console.log('timer1')
const promise2 = Promise.resolve().then(() => {
console.log('promise2');
const timer2 = setTimeout(() => {
console.log('timer2')
}, 0)
})
}, 0);
});

const timer3 = setTimeout(() => {
console.log('timer3');
const promise3 = new Promise(resolve => {
setTimeout(() => {
console.log('promise3');
resolve();
}, 0);
}).then(() => {
console.log('promise3 then');
})
}, 0);

async function asyncFunction() {
console.log('async start');
await new Promise(resolve => setTimeout(resolve, 0));
console.log('async middle');
await Promise.resolve().then(() => console.log('async promise'));
console.log('async end');
}

asyncFunction();

console.log('end');
Please open Telegram to view this post
VIEW IN TELEGRAM



group-telegram.com/reactify_IT/1399
Create:
Last Update:

🖥 Задачи по Event Loop с собеседований

Задача №1


setTimeout(() => {
console.log('setTimeout')
})

const promise = new Promise((resolve, reject) => {
console.log(1);
setTimeout(() => {
console.log("timerStart");
resolve("success");
console.log("timerEnd");
}, 0);

Promise.resolve().then(() => {
console.log('resolve')
})
console.log(2);
});

promise.then((res) => {
console.log(res);
});

console.log(4);


Задача №2
setTimeout(function timeout() {
console.log('Таймаут 1');
}, 0);

let p = new Promise(function(resolve, reject) {
console.log('Создание промиса');

setTimeout(function timeout() {
console.log('Таймаут 2');
}, 0);

resolve();
});

p.then(function(){
console.log('Обработка промиса');
});

console.log('Конец скрипта');


Задача №3

const myPromise = (delay) => new Promise((res, rej) => { setTimeout(res, delay) })

setTimeout(() => console.log('in setTimeout1'), 1000);

myPromise(1000).then(res => console.log('in Promise 1'));

setTimeout(() => console.log('in setTimeout2'), 100);

myPromise(2000).then(res => console.log('in Promise 2'));

setTimeout(() => console.log('in setTimeout3'), 2000);

myPromise(1000).then(res => console.log('in Promise 3'));

setTimeout(() => console.log('in setTimeout4'), 1000);

myPromise(5000).then(res => console.log('in Promise '));


Задача №4

console.log(1);

setTimeout(() => console.log(2));

Promise.resolve().then(() => console.log(3));

Promise.resolve().then(() => setTimeout(() => console.log(4)));

Promise.resolve().then(() => console.log(5));

setTimeout(() => Promise.resolve().then(() => console.log(6)));

console.log(7);


Задача №5

console.log('start');

const promise1 = Promise.resolve().then(() => {
console.log('promise1');
const timer1 = setTimeout(() => {
console.log('timer1')
const promise2 = Promise.resolve().then(() => {
console.log('promise2');
const timer2 = setTimeout(() => {
console.log('timer2')
}, 0)
})
}, 0);
});

const timer3 = setTimeout(() => {
console.log('timer3');
const promise3 = new Promise(resolve => {
setTimeout(() => {
console.log('promise3');
resolve();
}, 0);
}).then(() => {
console.log('promise3 then');
})
}, 0);

async function asyncFunction() {
console.log('async start');
await new Promise(resolve => setTimeout(resolve, 0));
console.log('async middle');
await Promise.resolve().then(() => console.log('async promise'));
console.log('async end');
}

asyncFunction();

console.log('end');

BY Reactify | Frontend Разработка


Warning: Undefined variable $i in /var/www/group-telegram/post.php on line 260

Share with your friend now:
group-telegram.com/reactify_IT/1399

View MORE
Open in Telegram


Telegram | DID YOU KNOW?

Date: |

This ability to mix the public and the private, as well as the ability to use bots to engage with users has proved to be problematic. In early 2021, a database selling phone numbers pulled from Facebook was selling numbers for $20 per lookup. Similarly, security researchers found a network of deepfake bots on the platform that were generating images of people submitted by users to create non-consensual imagery, some of which involved children. The gold standard of encryption, known as end-to-end encryption, where only the sender and person who receives the message are able to see it, is available on Telegram only when the Secret Chat function is enabled. Voice and video calls are also completely encrypted. Oh no. There’s a certain degree of myth-making around what exactly went on, so take everything that follows lightly. Telegram was originally launched as a side project by the Durov brothers, with Nikolai handling the coding and Pavel as CEO, while both were at VK. The perpetrators use various names to carry out the investment scams. They may also impersonate or clone licensed capital market intermediaries by using the names, logos, credentials, websites and other details of the legitimate entities to promote the illegal schemes. Under the Sebi Act, the regulator has the power to carry out search and seizure of books, registers, documents including electronics and digital devices from any person associated with the securities market.
from us


Telegram Reactify | Frontend Разработка
FROM American