How to write transparent Chrome console wrapper?
I am trying to create simple Chrome console wrapper:
function debug() {
console.log(debug.arguments);
}
But it produces slightly different result from native console:
console.log("log",1,2,3); //outputs: log 1 2 3
debug("log",1,2,3); //outputs: ["log", 1, 2, 3]
Any idea how to make i开发者_开发问答t behave exactly the same?
This should work:
function debug() {
console.log.apply(console, arguments);
}
You can use bind
:
var debug = console.log.bind(console);
精彩评论