I'm filtering a an array in Jquery depending of some button selections of the user. I loop over the possibilities and build a "result" array extending it with a "original_array" slice.
result = []
$.each(university_selection, function(index, value) {
if ($(value).attr('name') == 'on') {
partial = jQuery.grep(original_array, function(n) { return ( n.institucion == $(value).text()); });
result = $.extend( result , partial )
};
});
The filterign works fine, but the "extend" command seems to replace previous instance instead of "accumulating". I only get the last slice returned.
I guess it has something to do with the moment in which the "result = $.extend( result , partial )" is stored in memory.
Any clues?