The Array.filter() method is having an asynchronous behavior.
According to the documentation, it seems to me it's not supposed to work that way.
Moreover,it does not allow the reference to a callback, as usual in such cases.
I am limited in relation to the use of libraries, but also confuses me, how it reacts that way.
I am not also expert in ECMAScript, am i making some mistake?
I just want to filter one array and send the results to a HTML select element as several options.
I have something like this:
var selCompanyDeps = departments.filter(fromSelectedCompany);
fillSelect($("#selDeparts"), selCompanyDeps, 'departmentID', 'name', selectedID);
function fromSelectedCompany(value){
var selectedCompany = $( "#SelComps" ).val();
return (value.companyID===Number(selectedCompany));
}
Thanks
.filteris not an async method.departmentscontain?