<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
</head>
<body>
</body>
<script src="script.js"></script>
</html>
function bind(f, th) {
var finalArgs = [].slice.call(arguments, 2);
return function() {
if (arguments) {
finalArgs = finalArgs.concat([].slice.call(arguments));
}
return f.apply(th, finalArgs);
};
}
function sum(a, b, c) {
log("sum inner", a, b, c);
return a + b + c;
}
function sumThis(a, b, c) {
log("sumThis inner", this.val, a, b, c);
return this.val + a + b + c;
}
log(bind(sum, null, 1)(2, 3));
log(bind(sum, null)(1, 2, 3));
log(bind(sumThis, {val: 4}, 1)(2, 3));
function log() {
document.body.innerHTML += "<br>" + [].slice.call(arguments).join(", ");
}
/* Styles go here */