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
await axios get
await axios get
Tránh viết biến có phạm vi global
Đôi khi bạn cần phải viết một tập lệnh trực tiếp trên trang. Cần lưu ý rằng trong code của bạn vô tình khai báo một biến toàn cầu. Vì phạm vi toàn cầu phức tạp hơn nên việc tìm kiếm chậm hơn rất nhiều
Rest Operator for Objects
Now we can use rest on the properties of an Object. It allows us to explicitly extract certain named variables, and assign any uncalled variables into a catchall Object.
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
kiểm tra email trong javascript
kiểm tra email trong javascript