Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Object doesn't support property or method 'filter'

I'm running into an IE8 issue which I initially thought was due to lack of IE8 support for indexOf() property but that didn't seem to be the case. I implemented the indexOf() through prototype but still keep getting the error messsage -

Object doesn't support property or method 'filter'

My code is and it errors out on the passedArray.filter line.

  function consolidatedFilters(passedArray, passedFilter, passedFilterType)
    if (passedFilterType == "specialty")
    {       
        var filteredArray = passedArray.filter(
            function(el)
            {
               for (i in passedFilter) 
               {
                    if (passedFilter[i] == el[8]) 
                    {
                        return true;
                    }
               }
               return false
             }
        );      
        return filteredArray;
    }
like image 389
firedrawndagger Avatar asked Sep 15 '11 14:09

firedrawndagger


1 Answers

Array.filter isn't cross-browser compliant, you'll have to prototype that onto Array. You also may want to verify that the array you are filtering is never typeof 'undefined'

Update: MDN provides a reference to how to prototype filter onto array: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/filter

like image 93
Skylar Anderson Avatar answered Oct 12 '22 13:10

Skylar Anderson