javascript - Delete element from a associative array in JavsScript --> very slow? -
i want delete 1 element associative array. array follows:
array[propertyname] = property;
this array filled data (less 10 entries) , shown in property window.
on pages can click delete button next entries , delete corresponding entry. achieve function called:
$d(document).on('click', '.property_del[type="button"]', function(event) { (property in selectedgroup.properties) { if(property == $d(this).attr('id').replace("_buttondel", "")){ continue; }else{ temp_array[property] = selectedgroup.properties[property]; } selectedgroup.properties = temp_array; });
this works far, selected entry deleted after button click event, slow hell. second method delete slow first one:
delete selectedgroup.properties[$d(this).attr('id').replace("_buttondel", "")];
what can make faster?
thx!!
maybe jquery selector inside loop slowing things down. speed things up:
$d(document).on('click', '.property_del[type="button"]', function(event) { var value = $d(this).attr('id').replace("_buttondel", ""); (property in selectedgroup.properties) { if(property == value){ continue; }else{ temp_array[property] = selectedgroup.properties[property]; } selectedgroup.properties = temp_array; });
Comments
Post a Comment