-
Notifications
You must be signed in to change notification settings - Fork 0
/
es5.js
55 lines (48 loc) · 979 Bytes
/
es5.js
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
46
47
48
49
50
51
52
53
54
55
//
// Missing methods for Windows Script Host
//
+function (){
if(!Object.create)
Object.create = function(proto) {
function fn() {}
fn.prototype = proto
return new fn
}
if(!Object.keys)
Object.keys = function(obj) {
var results = []
for (var k in obj)
results.push(k)
return results
}
if(!Array.isArray)
+function() {
var
toString = {}.toString,
ok = toString.call([])
Array.isArray = function(obj) {
return ok == toString.call(obj)
}
}()
var base = Array.prototype
if(!base.indexOf)
base.indexOf = function(el) {
for (var i = this.length - 1; i >= 0; i--)
if (el === this[i])
return i
return -1
}
if(!base.forEach)
base.forEach = function(fn) {
for (var i = 0, len = this.length; i < len; i++)
fn(this[i], i, this)
}
if(!base.filter)
base.filter = function(fn) {
var z, results = []
for (var i = 0, len = this.length; i < len; i++)
if (fn(z = this[i], i, this))
results.push(z)
return results
}
}()