Briefle
LearnGlossaryPricing

Briefle words · Code & architecture

instanceof check

Asking whether a value is of a given type, which is how code catches one specific kind of error and not another.

Say it to an AI

TypeScript getEpisode(id) service. Define custom error classes NotFoundError and ValidationError extending Error, throw them instead of strings or generic Errors, and map them to 404/400 in one httpStatus helper with instanceof checks, falling back to 500.

How an expert would brief the stronger version of “Episode lookup errors”.

See it

Try it as a puzzle →

Service function behind GET /episodes/:id in a podcast app, plus the helper that maps its errors to HTTP status codes.

Study A · the stronger one
Study B · the weaker one

Why: A's httpStatus uses 'e instanceof NotFoundError ? 404'. B uses 'String(e).includes("not found")', which breaks as soon as the wording changes.

Related words

  • Edge case
  • Guard clause
  • Swallowed exception
  • Fail fast
  • Side effect
  • Log level
  • Custom error class
  • Optional chaining

Room 4 · Errors & edge cases

Learn “instanceof check” in a five-minute lesson

Start free
AI can build almost anything. The bottleneck is saying what you want.
WordsPricingTermsPrivacyRefundsContact
© 2026 Briefle