Problem, as an interviewer would state it:
"Implement partial(fn, ...presetArgs) — returning a genuinely NEW function that, when LATER called, invokes fn with the preset arguments prepended to whatever new arguments the later call provides."
Examples:
function add3(a, b, c) { return a + b + c; }
const addTo5 = partial(add3, 5);
addTo5(2, 3); // 10
Clarifying questions expected:
- Does this need to support pre-filling MORE than one leading argument, not just the first?
- Should the ORIGINAL function remain genuinely unaffected/reusable after calling partial() on it?
- How does this genuinely differ from bind() — is partial application a distinct, real concept, or just a simplified bind?
Code / implementation expected: Yes — real, direct proof pre-filling both a single and multiple leading arguments, confirming the original function is genuinely unaffected and reusable afterward.