Hiển thị các bài đăng có nhãn Iterate. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn Iterate. Hiển thị tất cả bài đăng

Iterate over array of objects in Typescript

Source: https://stackoverflow.com/questions/46213989/iterate-over-array-of-objects-in-typescript

You can use the built-in forEach function for arrays.
Like this:
//this sets all product descriptions to a max length of 10 characters
data.products.forEach( (element) => {
    element.product_desc = element.product_desc.substring(0,10);
});
Your version wasn't wrong though. It should look more like this:
for(let i=0; i<data.products.length; i++){
    console.log(data.products[i].product_desc); //use i instead of 0
}

Renewing Facebook Graph API token automatically?

  Mã truy cập dài hạn https://developers.facebook.com/docs/facebook-login/guides/access-tokens/get-long-lived/ https://community.n8n.io/t/re...