This is because you have lost the console link. You simply call log directly, without context. You can call the function in the console context to make it work:
g.call(console, 1);
Or, so that you cannot do this every time, you can bind a function to a console object:
var g = console.log.bind(console);
References
source share