javascript同数组里的对象比较,相等的话对象里的值累加。 财富值64

2016-11-01 11:11发布

var arr = [{"code":"111","num":1},{"code":"112","num":1},{"code":"111","num":3},{"code":"113","num":1},{"code":"113","num":5},{"code":"111","num":1}] //像这样的一个数组,比较对象code,如果相等,取其num相加的值输出。