开发者

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 开发者_Go百科'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;
    }


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜