1Function.prototype.myBind = function(thisArg, ...boundArgs) {
2 // 'this' inside here is the function being bound
3 // return a new function that calls the original with the bound context
4};
5
6// Test runner — do not modify
7function solve(mode, ...args) {
8 if (mode === "basic") {
9 const obj = { x: args[0] };
10 function getX() { return this.x; }
11 const bound = getX.myBind(obj);
12 return bound();
13 }
14 if (mode === "partial") {
15 function add(a, b) { return a + b; }
16 const add5 = add.myBind(null, args[0]);
17 return add5(args[1]);
18 }
19 if (mode === "multi-partial") {
20 function sum(a, b, c) { return a + b + c; }
21 const sumWith1and2 = sum.myBind(null, args[0], args[1]);
22 return sumWith1and2(args[2]);
23 }
24}
25