// Portable version of `log` that: // * Doesn't expose log to the window. // * Allows log() to be called above the function declaration. // Because of this, you can just throw it in the bottom of a plugin and it won't mess with global scope or clutter your code (function() { // Your code here... log() away function log () { /* jshint -W021 */ if (window.console) { // Only run on the first time through - reset this function to the appropriate console.log helper if (Function.prototype.bind) { log = Function.prototype.bind.call(console.log, console); } else { log = function() { Function.prototype.apply.call(console.log, console, arguments); }; } log.apply(this, arguments); } } })(); // All at once (minified version): function log(){/* jshint -W021 */if(window.console){if(Function.prototype.bind)log=Function.prototype.bind.call(console.log,console);else log=function(){Function.prototype.apply.call(console.log,console,arguments);};log.apply(this,arguments);}}