This wont work properly. You are setting a non-function value as the result, which will cause a crash if console.* is called. You need to define a wrapper function.