[英]how to remove a element of a array by its index value
我需要通过其索引值删除数组的元素。 我已经有了索引值,只需要拼接即可。 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
因此,只需使用splice
方法:
customSeriesSums[0].data.splice( customSeriesIndexMatch, 1 );
查看拼接文档 。
customSeriesSums[0].data.splice( customSeriesIndexMatch,1 );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.