Skip to content

Commit b09a4a1

Browse files
committed
Partial implementation and fun function.
1 parent 572b77b commit b09a4a1

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

js/scratch-pad.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,31 @@
5050

5151
Sample.whatTheFuncOut = Sample.whatTheFunc(Sample.whatTheFuncData)('What')('the');
5252

53-
return context.Sample = Sample;
53+
Sample.add = function () {
54+
console.log(this);
55+
var sum = 0;
56+
for (var i = 0, len = arguments.length; i < len; i++) {
57+
sum += arguments[i];
58+
}
59+
return sum;
60+
};
5461

5562
var val = 2;
5663
Sample.hash = {2: 'A', 6: 'B', 9: 'C', '2': 'D'};
5764
Sample.hashAccess1 = {2: 'A', 6: 'B', 9: 'C', '2': 'D'}[val];
5865
Sample.hashAccess2 = Sample.hash[val];
66+
67+
return context.Sample = Sample;
5968
})(this)
69+
70+
Function.prototype.partial = function () {
71+
// slice is shorter and I am a lazy.
72+
var slice = Array.prototype.slice;
73+
var func = this;
74+
var args = slice.apply(arguments);
75+
76+
return function () {
77+
debugger
78+
return func.apply(this, args.concat(slice.apply(arguments)));
79+
};
80+
};

0 commit comments

Comments
 (0)