Restore console functions in JS

December 28th, 2016 | Permalink

Naughty boys and girls sometimes replace browser’s console object from window object to eliminate debug messages from scripts (instead of just redefining it inside closure). There IS a way to restore it. I do it like this:

  window.console = ifr.contentWindow.console;

‘course, this should be done after the DOM is ready, I guess. Most cases I use it I’m fiddling in browser’s console and have no access to page source anyway.

Also I was lazy to hard-code the latin alphabet and did this:

Array.apply(0,Array(26)).map(function(a,i){return String.fromCharCode(i+97);});
// ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

And yea, I was bored.