Closed rdking closed 3 years ago
I don't think that's the case.
Over here it states that Error.prototype.stack is a getter, and returns the result of the getStackString operation, which in turn gives back a string.
Error.prototype.stack being a non-string would break the web, which is why the current spec has it outputting a string.
Error.getStack
or the equivalent would be what outputs an object structure.
Unless I misread the spec document, the result of
(new Error).stack
will be an object. Currently, albeit non-standard it is always a string where implemented. Won't that break anything existing that does any stack inspection? Wouldn't it be more backwards compatible to spec it as a string, then define a separate property or function to return the object the spec describes?