I think he wants you to realize that calling f
returns another function.
function f(a, b, c) {
return function() {
return a[b](c);
}
}
This is a function that, when run, returns another function. So
window.onload = f(document, "write", "hi!");
ends up being something like
window.onload = function() { return a[b](c); }
where a
, b
, and c
are bound to the values you passed in. So write something like that, but replace a
, b
, and c
with the right values. It ends up being return document["write"]("hi")
which can also be written return document.write("hi")
. Plug that in:
window.onload = function() {
return document.write("hi");
}
This is equivalent.