polyfill.filter-uncompressed.js
1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* Polyfill service v3.14.0
* For detailed credits and licence information see https://github.com/financial-times/polyfill-service.
*
* UA detected: ie/8.0.0
* Features requested: Array.prototype.filter
*
* - Array.prototype.filter, License: CC0 */
(function(undefined) {
if (!('filter' in Array.prototype)) {
// Array.prototype.filter
Array.prototype.filter = function filter(callback) {
if (this === undefined || this === null) {
throw new TypeError(this + ' is not an object');
}
if (!(callback instanceof Function)) {
throw new TypeError(callback + ' is not a function');
}
var
object = Object(this),
scope = arguments[1],
arraylike = object instanceof String ? object.split('') : object,
length = Math.max(Math.min(arraylike.length, 9007199254740991), 0) || 0,
index = -1,
result = [],
element;
while (++index < length) {
element = arraylike[index];
if (index in arraylike && callback.call(scope, element, index, object)) {
result.push(element);
}
}
return result;
};
}
})
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});