0

I working on a project where the console is overwritten:

window.console = {};
window.console['log'] = function() {};

is there another way to write something to the console?

Also other methods, like warn or error are overwritten.

Maybe there is another reference to window.console?

nbar
  • 6,028
  • 2
  • 24
  • 65
  • 1
    _Why_ is it overwritten …? – CBroe Nov 13 '13 at 13:26
  • they overwrite console methods to create warn,alert methods here:[print debug messages javascript console](http://stackoverflow.com/questions/217957/how-to-print-debug-messages-in-the-google-chrome-javascript-console) – AlvaroAV Nov 13 '13 at 13:26
  • get another reference to console before its overwritten then use that. but why are you overwriting those properties? if its like the 2nd answer in the q Liarez linked too above, they should still be pointing at their old native implementations, not overwritten to empty function just to prevent runtime errors. – Daniel Robinson Nov 13 '13 at 13:27
  • possible duplicate of [Access window.console after overwrite](http://stackoverflow.com/questions/7081433/access-window-console-after-overwrite) – Tibos Nov 13 '13 at 13:30

1 Answers1

0

Before overwriting the original console methods, copy it to a different variable:

var OriginalConsole = console;
OriginalConsole.log('test'); //logs test to the console

I'm not sure why you would actually want to overwrite the default console or error functions, but there you have it.

Milanzor
  • 1,920
  • 14
  • 22
  • 1. its not my code that overwrites the console. 2. my code is executed later -> can't backup the originalconsole. So, it looks like it's not possible – nbar Nov 13 '13 at 14:59