如何更新数组内列表上的项目?

时间:2018-10-15 00:40:48

标签: javascript arrays list

鉴于此数据结构,我需要进行每个计算(“ totalAssets”-“ shareholderEquity”)。在javascript中效果如何。非常感谢。

{
    "symbol": "FB",
    "financials": [
        {
            "reportDate": "2017-12-31",
            "totalAssets": 84524000000,
            "totalLiabilities": null,
            "shareholderEquity": 74347000000,
        },
        {
            "reportDate": "2016-12-31",
            "totalAssets": 64961000000,
            "totalLiabilities": null,
            "shareholderEquity": 59194000000,
        },
        {
            "reportDate": "2015-12-31",
            "totalAssets": 49407000000,
            "totalLiabilities": null,
            "shareholderEquity": 44218000000,
        },
        {
            "reportDate": "2014-12-31",
            "totalAssets": 39966000000,
            "totalLiabilities": null,
            "shareholderEquity": 36096000000,
        }
    ]
}

2 个答案:

答案 0 :(得分:0)

您可以使用arrow functions遍历集合中的项目并执行分配。

delete

答案 1 :(得分:0)

var i = 0;
$('.slick-next').click(function(){
    console.log('next clicked');
    i++;
    console.log(i);
    if (i==1) {
        $('#people').css('filter', 'none');
    }
})