我需要通过索引值删除数组元素。我有索引值,我只需要拼接它。 customSeriesIndexMatch是我需要从customSeriesSums.data
中删除的索引号var dataPointSum = 101100;
console.log(customSeriesSums[0].data);
// loop through customSeriesSums and match with dataPointSum
var index = customSeriesSums[0].data.indexOf(dataPointSum);
var customSeriesIndexMatch = index + 1
console.log("DataPointSum : " + dataPointSum + " " + "Matched with customSeriesSum Index : " + customSeriesIndexMatch);
// now I need to remove the customSeriesSums.data array by its index that equals customSeriesIndexMatch
答案 0 :(得分:3)
所以只需使用splice
方法:
customSeriesSums[0].data.splice( customSeriesIndexMatch, 1 );
答案 1 :(得分:2)
查看splice docs。
customSeriesSums[0].data.splice( customSeriesIndexMatch,1 );