score:2

Accepted answer

looks like your code is modifying the array that is being iterated over. try this and observe the logs.

$.each(chart.series, function(i,ser) {        
        console.log(i + " / " + chart.series.length);
        ser.remove();        
});

observe how the current index i is increasing and your series length is decreasing after each iteration.

0 / 4
1 / 3
2 / 2 << chart.series[2] becomes undefined for chart.series.length=2

at the third iteration, i=2 & chart.series.length=2 => ser=undefined

proper way to remove all series data from a highcharts chart? provides the right way of doing this. always remove the series at index 0 if it exists.

while(chart.series.length > 0)
    chart.series[0].remove(true);

Related Query

More Query from same tag