Problem, as an interviewer would state it:
"Implement Function.prototype.myCall and myApply from scratch — WITHOUT using the real native .call/.apply themselves — correctly binding this and forwarding arguments."
Examples:
function greet(greeting) { return greeting + ", " + this.name; }
greet.myCall({ name: "Ada" }, "Hello"); // "Hello, Ada"
Clarifying questions expected:
- Since this can't use real .call/.apply internally, what's the genuine mechanism for actually invoking the function WITH a specific this binding?
- Does the temporary technique used to achieve this need to avoid leaving any trace (a leaked property) on the real context object afterward?
- What is the real, correct default this binding if thisArg is null/undefined?
Code / implementation expected: Yes — real, direct proof that this is correctly bound and arguments correctly forwarded, PLUS a real, direct check confirming no property leaks onto the context object afterward.