开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜