I have an array of objects in JavaScript. e.g. current_films[0].f_name, current_films[0].f_pattern etc. I want to copy the array into another similiar to the following:
for(var i=0; i<current_films.length; i++)
{
if(current_films[i].f_material == Value)
{
temp[i] = current_films[i];
}
}
However, there seems to be an inexplicable problem when I do this. By inexplicable problem, I mean that the code does not execute and the array is not copied as I desire.
Any help would be greatly appreciated. Thank you!
P.S. Could you please mention why the above code would not work? As in, if I put an alert("Reached here");, it's not getting executed. Any ideas why its so?
Value? Can you give us a sample data that you expect to get?temparray will be sparse -- the indexes will not be sequential from 0, only the indexes fromcurrent_filmthat matchValuewill exist. Is that the problem?Valueis just a string. Right now, I am just trying to copy all those objects whosef_materialattribute matchesValue