Skip to content

Instantly share code, notes, and snippets.

@devarajchidambaram
Created February 28, 2019 06:15
Show Gist options
  • Save devarajchidambaram/9a5651a68cb885fb530d5f594855b8bb to your computer and use it in GitHub Desktop.
Save devarajchidambaram/9a5651a68cb885fb530d5f594855b8bb to your computer and use it in GitHub Desktop.
captureStackTrace
Error.captureStackTrace(targetObject[, constructorOpt])#
targetObject <Object>
constructorOpt <Function>
Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // similar to `new Error().stack`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment