I am working on client side scripts and need to do heavy computations like pushing huge number of objects in an array, it causes JavaScript to stop response and browser hangs giving an alert:
Is there any best practices or design patterns for handling these computation, I search and find many different ways to handle these situation but solutions are difficult to implement so I need best practices and easy to understand?
(I am writing code just for example But I need a general solution that is cross-browser i.e, multi-threading etc)
Example Code (series contains thousands of objects):
for (var series = 0; series < chartObj.masterChart.series.length; series++) {
var detailData = [];
jQuery.each(chartObj.masterChart.series[series].data, function (i, point) {
if (point.x >= chartObj.RangeSelectedMinValue && point.x <= chartObj.RangeSelectedMaxValue) {
detailData.push({
x: point.x,
y: point.y
});
}
});
chartObj.detailChart.series[series].setData(detailData);
}