Each step will be separated by a newline, with the first part of the line being the function name (if not a call from the global scope), then by an at (@) sign, the file location (except when the function is the error constructor as the error is being thrown), a colon, and, if there is a file location, the line number. (Note that the Error
object also possesses the fileName
, lineNumber
and columnNumber
properties for retrieving these from the error thrown (but only the error, and not its trace).)
Note that this is the format used by Firefox. There is no standard formatting. However, Safari 6+ and Opera 12- use a very similar format. Browsers using the V8 JavaScript engine (such as Chrome, Opera 15+, Android Browser) and IE10+, on the other hand, uses a different format (see the archived MSDN error.stack docs).
Argument values in the stack: Prior to Firefox 14, the function name would be followed by the argument values converted to string in parentheses immediately before the at (@
) sign. While an object (or array, etc.) would appear in the converted form "[object Object]"
, and as such could not be evaluated back into the actual objects, scalar values could be retrieved (though it may be — it is still possible in Firefox 14 — easier to use arguments.callee.caller.arguments
, as could the function name be retrieved by arguments.callee.caller.name
). "undefined"
is listed as "(void 0)"
. Note that if string arguments were passed in with values such as "@"
, "("
, ")"
(or if in file names), you could not easily rely on these for breaking the line into its component parts. Thus, in Firefox 14 and later this is less of an issue.
Different browsers set this value at different times. For example, Firefox sets it when creating an Error
object, while PhantomJS sets it only when throwing the Error
, and archived MSDN docs also seem to match the PhantomJS implementation.