方法說明:
向標準錯誤流輸出目前的呼叫堆疊。
文法:
console.trace(label)
接收參數:
label
範例:
console.trace();
//運行結果:
Trace:
at Object.
(/home/byvoid/consoletrace.js : 1: 71)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
at Array.0 (module.js:479:10)
at EventEmitter._tickCallback (node.js:192:40)
原始碼:
Console.prototype.trace = function() {
// TODO probably can to do this better with V8's debug object once that is
// exposed.
var err = new Error;
err.name = 'Trace';
err.message = util.format.apply(this, arguments);
Error.captureStackTrace(err, arguments.callee);
this.error(err.stack);
};