Last active
July 23, 2021 16:33
-
-
Save vovk1805/ff960d3127331f6f7c57be68b57164f2 to your computer and use it in GitHub Desktop.
Async filter JS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
}); | |
// після фільтрації тут мав би бути пустий масив | |
console.log('result ↓↓↓↓↓↓↓↓↓↓↓↓↓'); | |
console.dir(result, { depth: 10000, colors: true }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment