Await in a for loop
function,es6,async,tipjs
How to Await in a for loop
const forLoop = async _ => {
console.log('Start')
for (let index = 0; index < fruitsToGet.length; index++) {
const fruit = fruitsToGet[index]
const numFruit = await getNumFruit(fruit)
console.log(numFruit)
}
console.log('End')
}
//Use:
'Start'
'Apple: 27'
'Grape: 0'
'Pear: 14'
'End'
Có thể bạn đã miss một số snippets code
Filter Unique Values
Kiểu đối tượng Set đã được giới thiệu trong ES6 và cùng với ..., ‘spread’ operator, chúng ta có thể sử dụng nó để tạo một mảng mới chỉ với các giá trị duy nhất.
Làm phẳng mảng dùng phương pháp đệ quy
Làm phẳng mảng dùng phương pháp đệ quy
Getting the last element of a split string array
Getting the last element of a split string array
Lấy tháng hiện tại trong javascript
Lấy tháng hiện tại trong javascript
Extend Object javascript
Extend Object javascript