Array.filter()
isn't included in IE until version 9.
You could use this to implement it:
if (!Array.prototype.filter)
{
Array.prototype.filter = function(fun /*, thisp */)
{
"use strict";
if (this === void 0 || this === null)
throw new TypeError();
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun !== "function")
throw new TypeError();
var res = [];
var thisp = arguments[1];
for (var i = 0; i < len; i++)
{
if (i in t)
{
var val = t[i]; // in case fun mutates this
if (fun.call(thisp, val, i, t))
res.push(val);
}
}
return res;
};
}
From: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/filter
Or since you are using jQuery, you can wrap your array into a jQuery object first:
songs = $(songs).filter(function(){
return this.album==album;
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…