Created
November 9, 2016 08:37
-
-
Save katopz/1526964b4854c5c9796b43ed9af7b289 to your computer and use it in GitHub Desktop.
Playing with console
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Will print... [2016-11-09T07:52:09.303Z] foo bar | |
// ES6 | |
var _log = _log || console.log; | |
console.log = (...arguments) => { | |
arguments.unshift(`[${new Date().toISOString()}]`) | |
_log.apply(console, arguments); | |
}; | |
console.log('foo', 'bar'); | |
// ES5 | |
var _log = _log || console.log; | |
console.log = function() { | |
const args = Array.prototype.slice.call(arguments); | |
args.unshift(`[${new Date().toISOString()}]`) | |
_log.apply(console, args); | |
}; | |
console.log('foo', 'bar'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment