-
-
Save adriancmiranda/840c1489e0d89d9eb811e3e5cea9a4f7 to your computer and use it in GitHub Desktop.
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
// original (broken) version is here: http://ivan-ghandhi.livejournal.com/942493.html | |
// My fix: don't treat arguments as if it were an array | |
// (Use Array.prototype.slice.call() to convert it) | |
function stackTrace() { | |
var err = new Error(); | |
console.log(typeof err.stack); | |
return err.stack; | |
} | |
function stacktrace() { | |
function st2(fn) { | |
if (!fn) return []; | |
var args = JSON.stringify(Array.prototype.slice.call(fn.arguments)); | |
var fnName = fn.toString().split('(')[0].substring(9); | |
return st2(fn.caller).concat([fnName + '(' + args + ')']); | |
} | |
return st2(arguments.callee.caller); | |
} | |
function test(arg1, arg2){ | |
//return console.trace('ae') | |
return stackTrace(); | |
//return stacktrace(); | |
} | |
test('ae', new Array()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment