Can you solve this problem without error? The answer is single-line. This is from a dead vacancy, the answer was requested in the answer. I thought this was a smart way to weed out respondents, but I can't answer it without errors.
The obvious solution:
f.moo(alert(f.foo));
But it throws TypeError: callback is undefined { message="callback is undefined", more...}
var f = (function(){
return {
foo : "bar",
moo : function(callback){
callback.call(this)
}
}
})();
source
share