-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunction.call3.html
More file actions
78 lines (73 loc) · 1.72 KB
/
function.call3.html
File metadata and controls
78 lines (73 loc) · 1.72 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script>
function call2(ctx) {
var context = ctx || window;
var arr = [];
context.fn = [].shift.call(arguments);
for (var i = 0, l = arguments.length; i < l; i++) {
][]
}
}
function deepCopy(obj) {
var res = null;
if (typeof obj === 'object') {
res = obj.constructor === Array ? []: {};
for (var i in obj) {
obj[i] = typeof obj[i] === 'object' ? deepCopy(obj[i]) : obj[i];
}
return res;
} else {
res = obj
}
return res;
}
function Person(name) {
this.name = name;
}
function Child(name, parentName) {
Person.call(this, parentName);
this.name = name;
}
function create(o) {
function F() {};
F.prototype = o;
return new F();
}
Child.prototype = create(Person.prototype);
Child.prototype.Constructor = Child;
function new2() {
var obj = Object.create(null),
Constructor = [].shift.call(arguments);
obj.__proto__ = Constructor.prototype;
var res = Constructor.apply(obj, arguments);
return typeof res === 'object' ? res : obj;
}
function curry(fn, args) {
var length = fn.length;
var args = args || [];
return function() {
newArgs = args.concat(Array.prototype.slice.call(arguments));
if (newArgs.length < length) {
return curry.call(this,fn,newArgs);
}else{
return fn.apply(this,newArgs);
}
}
}
function multiFn(a, b, c) {
return a * b * c;
}
var multi = curry(multiFn);
console.log(multi(2)(3)(4));
// console.log(multi(2,3,4));
// console.log(multi(2)(3,4));
// console.log(multi(2,3)(4));
</script>
</body>
</html>