Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumJavaScriptError subclassingSingle-choice MCQ

Why is checking err instanceof CustomError sometimes unreliable when Error is subclassed in code compiled by older transpilers (targeting ES5)?

class CustomError extends Error {} const err = new CustomError('x'); console.log(err instanceof CustomError);