Skip to content

Instantly share code, notes, and snippets.

View vovk1805's full-sized avatar
๐Ÿ‡บ๐Ÿ‡ฆ
#StandWithUkraine

Volodymyr Vovk vovk1805

๐Ÿ‡บ๐Ÿ‡ฆ
#StandWithUkraine
View GitHub Profile
setTimeout(() => console.log(1));
setTimeout(() => {
console.log(2);
process.nextTick(() => console.log('Inside nextTick'));
});
setTimeout(() => console.log(3));
setTimeout(() => console.log(4));
setTimeout(() => console.log(1));
setTimeout(() => {
console.log(2);
Promise.resolve().then(() => console.log('Inside Promise.resolve'));
});
setTimeout(() => console.log(3));
setTimeout(() => console.log(4));
@vovk1805
vovk1805 / asyncForEach.js
Last active July 23, 2021 16:22
Async forEach JS
const promise = new Promise((res) => res('lol'));
const arr = [1, 2, 3, 4, 5];
const result = [];
arr.forEach(async (el) => {
const res = await promise;
if (res === 'lol') {
result.push(el);
@vovk1805
vovk1805 / asyncFilter.js
Last active July 23, 2021 16:33
Async filter JS
const promise = new Promise((res) => res('lol'));
const arr = [1, 2, 3, 4, 5];
const result = arr.filter(async (el) => {
const res = await promise;
if (res !== 'lol') {
return el;
}