2015-05-27 3 views
1

Мне нужно удалить элемент массива по его значению индекса. У меня есть значение индекса, мне просто нужно его сплайсировать. CustomSeriesIndexMatch указан порядковый номер, что мне нужно удалить из customSeriesSums.dataКак удалить элемент массива по его значению индекса

fiddle

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 

ответ

3

Так просто использовать splice метод:

customSeriesSums[0].data.splice(customSeriesIndexMatch, 1);