What is the difference between `Error.captureStackTrace()` and a regular `new Error()` in terms of stack trace manipulation?

JavaScript Developer Hard

JavaScript Developer — Hard

What is the difference between `Error.captureStackTrace()` and a regular `new Error()` in terms of stack trace manipulation?

Key points

  • Error.captureStackTrace() customizes stack traces in V8
  • new Error() captures full stack, including constructor calls
  • V8-specific feature for clean error classes
  • Difference lies in stack trace customization

Ready to go further?

Related questions