VIEW THIS AS

Auto mode follows the Route Engine until you choose a viewpoint.

YOU ARE HERE

ROUTE CHECK

CONNECTED TO

WHAT NEXT

Use the canonical route for this room, or HELP if you are unsure.

The Gold Standard of Websites | Separating Error.isError Brand Checks from instanceof Across Realms

Error.isError answers a narrow brand question: does this object carry the internal Error data slot used by built-in Error objects? That question differs from whether a value inherits from the current realm’s Error.prototype, has the name ‘Error’, prints with an Error tag or merely resembles an error record. The distinction becomes clearest when values cross realm boundaries.

This specialist guide belongs to the Websites root. It also connects to The Gold Standard of Education | Learning That Transfers into Life and the How X Works hub. The worked cases are original teaching examples; their values and event logs are stated so each conclusion can be checked.

eduKateSG · Websites

Find your next learning step

Follow the routes to compare internal Error branding, instanceof prototype checks, cross-realm values, subclasses, look-alikes, custom tags, proxies and the separate application decision about what may safely be logged or shown.

ROUTE 1 · CHAPTERS 1–3

Build the first model

Name the input, state, conversion or predicate before following user-visible results.

ROUTE 2 · CHAPTERS 4–5

Trace the decisive branch

Work the accepted path and the nearest boundary case with original examples.

ROUTE 3 · CHAPTERS 6–8

Change one premise

Rebuild the mechanism when state, value, realm, timing or object kind changes.

ROUTE 4 · CHAPTERS 9–10

Handle limits and failures

Keep abrupt completion, availability and application limits visible.

ROUTE 5 · CHAPTERS 11–12

Verify and explain

Use a decisive fixture, changed-context check and concise final account.

Full chapter contents · Websites subject guide

Chapter contents

Build the first model · Chapters 1–3

1. Ask the brand question precisely

2. Compare with local instanceof

3. Cross a realm boundary

Trace the decisive branch · Chapters 4–5

4. Keep built-in Error subclasses branded

5. Handle custom Error subclasses

Change one premise · Chapters 6–8

6. Reject a plain look-alike

7. Do not trust a custom toStringTag

8. Treat proxies as a separate boundary

Handle limits and failures · Chapters 9–10

9. Keep serialized error records distinct

10. Check availability before using a new method

Verify and explain · Chapters 11–12

11. Choose the next operation, not a universal label

12. Explain realms, brands and records in order

CHAPTER 1 OF 12 · Build the first model

1. Ask the brand question precisely

Back to contents

The short answer is that Error.isError returns true only for an object with the internal ErrorData slot and false for non-objects or look-alikes. Chapter 1 focuses on ask the brand question precisely. Begin with the candidate value, its realm, ErrorData internal slot, local constructor and prototype chain, subclass brand, custom name and Symbol.toStringTag, proxy boundary, structured data fields and the operation the caller actually needs. Writing those facts first prevents a familiar label or final console line from replacing the operation that actually decides the result.

Worked example. Test new Error(‘offline’) and obtain true. Treat every stated value as part of a controlled teaching fixture. Record the starting state before the call, then record each conversion, lookup, check or state transition in order. Stop the trace when an abrupt completion occurs; later effects are not inferred from what normally would have happened.

A useful first-principles question for ask the brand question precisely is: what must already be true before this step can run? Use the rule above to separate the input contract from the result. Follow object identity, state and returned value independently. Two branches can print similar data while differing in ownership, timing, brand or future capability.

Now change exactly one premise. Test null, a string and a plain record with name and message fields. Recalculate the trace from the changed fact rather than editing the old conclusion. Name the earliest event that differs, carry that difference through the remaining steps, and say which observations stay the same because their prerequisites did not change.

The main limit is this: A true brand does not prove the message is trustworthy or safe to display. Keep language semantics separate from processor strategy, host scheduling, browser support, trust policy and the meaning assigned by an application. A focused example can establish the stated mechanism without pretending to settle those broader questions.

Practical evidence check. Record brand result separately from chosen logging policy. Capture returned values and thrown error classes, but also preserve the event log that led to them. A test that asserts only the last value can pass even when an earlier conversion, constructor, iterator close, atomic operation or realm boundary was wrong.

A concise final explanation of ask the brand question precisely should state the starting state, the governing rule, the ordered outcome and one boundary. It should not depend on a screenshot, engine message wording or an unstated timing assumption. That form is short enough for revision and precise enough for a code review or debugging note.

Contents · Next chapter

CHAPTER 2 OF 12 · Build the first model

2. Compare with local instanceof

Back to contents

The short answer is that instanceof normally asks whether the constructor’s prototype participates in the candidate’s chain, a different mechanism from ErrorData. Chapter 2 focuses on compare with local instanceof. Begin with the candidate value, its realm, ErrorData internal slot, local constructor and prototype chain, subclass brand, custom name and Symbol.toStringTag, proxy boundary, structured data fields and the operation the caller actually needs. Writing those facts first prevents a familiar label or final console line from replacing the operation that actually decides the result.

Worked example. Create a local TypeError and observe both local instanceof Error and Error.isError as true. Treat every stated value as part of a controlled teaching fixture. Record the starting state before the call, then record each conversion, lookup, check or state transition in order. Stop the trace when an abrupt completion occurs; later effects are not inferred from what normally would have happened.

A useful first-principles question for compare with local instanceof is: what must already be true before this step can run? Use the rule above to separate the input contract from the result. Follow object identity, state and returned value independently. Two branches can print similar data while differing in ownership, timing, brand or future capability.

Now change exactly one premise. Change the prototype of a branded Error and compare the results. Recalculate the trace from the changed fact rather than editing the old conclusion. Name the earliest event that differs, carry that difference through the remaining steps, and say which observations stay the same because their prerequisites did not change.

The main limit is this: Prototype mutation can affect instanceof without erasing the internal Error brand. Keep language semantics separate from processor strategy, host scheduling, browser support, trust policy and the meaning assigned by an application. A focused example can establish the stated mechanism without pretending to settle those broader questions.

Practical evidence check. Capture prototype identity and both predicates. Capture returned values and thrown error classes, but also preserve the event log that led to them. A test that asserts only the last value can pass even when an earlier conversion, constructor, iterator close, atomic operation or realm boundary was wrong.

A concise final explanation of compare with local instanceof should state the starting state, the governing rule, the ordered outcome and one boundary. It should not depend on a screenshot, engine message wording or an unstated timing assumption. That form is short enough for revision and precise enough for a code review or debugging note.

Contents · Previous chapter · Next chapter

CHAPTER 3 OF 12 · Build the first model

3. Cross a realm boundary

Back to contents

The short answer is that an Error created in another realm carries ErrorData but does not normally inherit from the current realm’s Error.prototype. Chapter 3 focuses on cross a realm boundary. Begin with the candidate value, its realm, ErrorData internal slot, local constructor and prototype chain, subclass brand, custom name and Symbol.toStringTag, proxy boundary, structured data fields and the operation the caller actually needs. Writing those facts first prevents a familiar label or final console line from replacing the operation that actually decides the result.

Worked example. Create an iframe or other controlled realm Error and test it in the receiving realm. Treat every stated value as part of a controlled teaching fixture. Record the starting state before the call, then record each conversion, lookup, check or state transition in order. Stop the trace when an abrupt completion occurs; later effects are not inferred from what normally would have happened.

A useful first-principles question for cross a realm boundary is: what must already be true before this step can run? Use the rule above to separate the input contract from the result. Follow object identity, state and returned value independently. Two branches can print similar data while differing in ownership, timing, brand or future capability.

Now change exactly one premise. Run the same pair of checks inside the originating realm. Recalculate the trace from the changed fact rather than editing the old conclusion. Name the earliest event that differs, carry that difference through the remaining steps, and say which observations stay the same because their prerequisites did not change.

The main limit is this: Realm construction and trust boundaries depend on the host; the language-level lesson is about distinct constructors and a shared brand definition. Keep language semantics separate from processor strategy, host scheduling, browser support, trust policy and the meaning assigned by an application. A focused example can establish the stated mechanism without pretending to settle those broader questions.

Practical evidence check. Log the candidate constructor realm without treating its name as proof. Capture returned values and thrown error classes, but also preserve the event log that led to them. A test that asserts only the last value can pass even when an earlier conversion, constructor, iterator close, atomic operation or realm boundary was wrong.

A concise final explanation of cross a realm boundary should state the starting state, the governing rule, the ordered outcome and one boundary. It should not depend on a screenshot, engine message wording or an unstated timing assumption. That form is short enough for revision and precise enough for a code review or debugging note.

Contents · Previous chapter · Next chapter

CHAPTER 4 OF 12 · Trace the decisive branch

4. Keep built-in Error subclasses branded

Back to contents

The short answer is that TypeError, RangeError, AggregateError and other built-in native errors carry the same ErrorData brand. Chapter 4 focuses on keep built-in error subclasses branded. Begin with the candidate value, its realm, ErrorData internal slot, local constructor and prototype chain, subclass brand, custom name and Symbol.toStringTag, proxy boundary, structured data fields and the operation the caller actually needs. Writing those facts first prevents a familiar label or final console line from replacing the operation that actually decides the result.

Worked example. Test one instance of each available built-in error constructor. Treat every stated value as part of a controlled teaching fixture. Record the starting state before the call, then record each conversion, lookup, check or state transition in order. Stop the trace when an abrupt completion occurs; later effects are not inferred from what normally would have happened.

A useful first-principles question for keep built-in error subclasses branded is: what must already be true before this step can run? Use the rule above to separate the input contract from the result. Follow object identity, state and returned value independently. Two branches can print similar data while differing in ownership, timing, brand or future capability.

Now change exactly one premise. Move one subclass instance across realms. Recalculate the trace from the changed fact rather than editing the old conclusion. Name the earliest event that differs, carry that difference through the remaining steps, and say which observations stay the same because their prerequisites did not change.

The main limit is this: A subclass name does not create a separate answer to Error.isError. Keep language semantics separate from processor strategy, host scheduling, browser support, trust policy and the meaning assigned by an application. A focused example can establish the stated mechanism without pretending to settle those broader questions.

Practical evidence check. Verify true while preserving the specific constructor or name only as diagnostic detail. Capture returned values and thrown error classes, but also preserve the event log that led to them. A test that asserts only the last value can pass even when an earlier conversion, constructor, iterator close, atomic operation or realm boundary was wrong.

A concise final explanation of keep built-in error subclasses branded should state the starting state, the governing rule, the ordered outcome and one boundary. It should not depend on a screenshot, engine message wording or an unstated timing assumption. That form is short enough for revision and precise enough for a code review or debugging note.

Contents · Previous chapter · Next chapter

CHAPTER 5 OF 12 · Trace the decisive branch

5. Handle custom Error subclasses

Back to contents

The short answer is that an ordinary subclass constructed through Error inherits Error’s internal initialization and remains branded. Chapter 5 focuses on handle custom error subclasses. Begin with the candidate value, its realm, ErrorData internal slot, local constructor and prototype chain, subclass brand, custom name and Symbol.toStringTag, proxy boundary, structured data fields and the operation the caller actually needs. Writing those facts first prevents a familiar label or final console line from replacing the operation that actually decides the result.

Worked example. Define class ValidationError extends Error and construct it normally. Treat every stated value as part of a controlled teaching fixture. Record the starting state before the call, then record each conversion, lookup, check or state transition in order. Stop the trace when an abrupt completion occurs; later effects are not inferred from what normally would have happened.

A useful first-principles question for handle custom error subclasses is: what must already be true before this step can run? Use the rule above to separate the input contract from the result. Follow object identity, state and returned value independently. Two branches can print similar data while differing in ownership, timing, brand or future capability.

Now change exactly one premise. Return a plain object explicitly from a custom constructor and compare the result. Recalculate the trace from the changed fact rather than editing the old conclusion. Name the earliest event that differs, carry that difference through the remaining steps, and say which observations stay the same because their prerequisites did not change.

The main limit is this: The class declaration text alone does not brand an arbitrary replacement object. Keep language semantics separate from processor strategy, host scheduling, browser support, trust policy and the meaning assigned by an application. A focused example can establish the stated mechanism without pretending to settle those broader questions.

Practical evidence check. Check Error.isError, instanceof ValidationError and own application fields separately. Capture returned values and thrown error classes, but also preserve the event log that led to them. A test that asserts only the last value can pass even when an earlier conversion, constructor, iterator close, atomic operation or realm boundary was wrong.

A concise final explanation of handle custom error subclasses should state the starting state, the governing rule, the ordered outcome and one boundary. It should not depend on a screenshot, engine message wording or an unstated timing assumption. That form is short enough for revision and precise enough for a code review or debugging note.

Contents · Previous chapter · Next chapter

CHAPTER 6 OF 12 · Change one premise

6. Reject a plain look-alike

Back to contents

The short answer is that properties such as name, message, stack and cause can be copied onto an ordinary object without installing ErrorData. Chapter 6 focuses on reject a plain look-alike. Begin with the candidate value, its realm, ErrorData internal slot, local constructor and prototype chain, subclass brand, custom name and Symbol.toStringTag, proxy boundary, structured data fields and the operation the caller actually needs. Writing those facts first prevents a familiar label or final console line from replacing the operation that actually decides the result.

Worked example. Create {name:’Error’,message:’offline’,stack:’…’} and observe false. Treat every stated value as part of a controlled teaching fixture. Record the starting state before the call, then record each conversion, lookup, check or state transition in order. Stop the trace when an abrupt completion occurs; later effects are not inferred from what normally would have happened.

A useful first-principles question for reject a plain look-alike is: what must already be true before this step can run? Use the rule above to separate the input contract from the result. Follow object identity, state and returned value independently. Two branches can print similar data while differing in ownership, timing, brand or future capability.

Now change exactly one premise. Add Error.prototype to its prototype chain and compare instanceof and Error.isError. Recalculate the trace from the changed fact rather than editing the old conclusion. Name the earliest event that differs, carry that difference through the remaining steps, and say which observations stay the same because their prerequisites did not change.

The main limit is this: Surface resemblance may be useful for a wire record but is not the built-in Error brand. Keep language semantics separate from processor strategy, host scheduling, browser support, trust policy and the meaning assigned by an application. A focused example can establish the stated mechanism without pretending to settle those broader questions.

Practical evidence check. Inspect the record’s schema for its intended application instead of forcing it through Error APIs. Capture returned values and thrown error classes, but also preserve the event log that led to them. A test that asserts only the last value can pass even when an earlier conversion, constructor, iterator close, atomic operation or realm boundary was wrong.

A concise final explanation of reject a plain look-alike should state the starting state, the governing rule, the ordered outcome and one boundary. It should not depend on a screenshot, engine message wording or an unstated timing assumption. That form is short enough for revision and precise enough for a code review or debugging note.

Contents · Previous chapter · Next chapter

CHAPTER 7 OF 12 · Change one premise

7. Do not trust a custom toStringTag

Back to contents

The short answer is that Symbol.toStringTag can influence Object.prototype.toString output without adding ErrorData. Chapter 7 focuses on do not trust a custom tostringtag. Begin with the candidate value, its realm, ErrorData internal slot, local constructor and prototype chain, subclass brand, custom name and Symbol.toStringTag, proxy boundary, structured data fields and the operation the caller actually needs. Writing those facts first prevents a familiar label or final console line from replacing the operation that actually decides the result.

Worked example. Give a plain object the tag ‘Error’ and compare its printed tag with Error.isError. Treat every stated value as part of a controlled teaching fixture. Record the starting state before the call, then record each conversion, lookup, check or state transition in order. Stop the trace when an abrupt completion occurs; later effects are not inferred from what normally would have happened.

A useful first-principles question for do not trust a custom tostringtag is: what must already be true before this step can run? Use the rule above to separate the input contract from the result. Follow object identity, state and returned value independently. Two branches can print similar data while differing in ownership, timing, brand or future capability.

Now change exactly one premise. Give a genuine Error a different custom tag. Recalculate the trace from the changed fact rather than editing the old conclusion. Name the earliest event that differs, carry that difference through the remaining steps, and say which observations stay the same because their prerequisites did not change.

The main limit is this: Diagnostic labels and internal branding answer different questions. Keep language semantics separate from processor strategy, host scheduling, browser support, trust policy and the meaning assigned by an application. A focused example can establish the stated mechanism without pretending to settle those broader questions.

Practical evidence check. Assert the tag text and brand result as separate observations. Capture returned values and thrown error classes, but also preserve the event log that led to them. A test that asserts only the last value can pass even when an earlier conversion, constructor, iterator close, atomic operation or realm boundary was wrong.

A concise final explanation of do not trust a custom tostringtag should state the starting state, the governing rule, the ordered outcome and one boundary. It should not depend on a screenshot, engine message wording or an unstated timing assumption. That form is short enough for revision and precise enough for a code review or debugging note.

Contents · Previous chapter · Next chapter

CHAPTER 8 OF 12 · Change one premise

8. Treat proxies as a separate boundary

Back to contents

The short answer is that a Proxy wrapper does not itself gain the target’s internal ErrorData slot, so brand checks need not transparently unwrap it. Chapter 8 focuses on treat proxies as a separate boundary. Begin with the candidate value, its realm, ErrorData internal slot, local constructor and prototype chain, subclass brand, custom name and Symbol.toStringTag, proxy boundary, structured data fields and the operation the caller actually needs. Writing those facts first prevents a familiar label or final console line from replacing the operation that actually decides the result.

Worked example. Wrap a genuine Error in a Proxy and compare target and wrapper. Treat every stated value as part of a controlled teaching fixture. Record the starting state before the call, then record each conversion, lookup, check or state transition in order. Stop the trace when an abrupt completion occurs; later effects are not inferred from what normally would have happened.

A useful first-principles question for treat proxies as a separate boundary is: what must already be true before this step can run? Use the rule above to separate the input contract from the result. Follow object identity, state and returned value independently. Two branches can print similar data while differing in ownership, timing, brand or future capability.

Now change exactly one premise. Add get traps that imitate name and message properties. Recalculate the trace from the changed fact rather than editing the old conclusion. Name the earliest event that differs, carry that difference through the remaining steps, and say which observations stay the same because their prerequisites did not change.

The main limit is this: Forwarded property access is not the same as internal-slot identity. Keep language semantics separate from processor strategy, host scheduling, browser support, trust policy and the meaning assigned by an application. A focused example can establish the stated mechanism without pretending to settle those broader questions.

Practical evidence check. Record trap activity and avoid claiming the wrapper is interchangeable with the target for every built-in operation. Capture returned values and thrown error classes, but also preserve the event log that led to them. A test that asserts only the last value can pass even when an earlier conversion, constructor, iterator close, atomic operation or realm boundary was wrong.

A concise final explanation of treat proxies as a separate boundary should state the starting state, the governing rule, the ordered outcome and one boundary. It should not depend on a screenshot, engine message wording or an unstated timing assumption. That form is short enough for revision and precise enough for a code review or debugging note.

Contents · Previous chapter · Next chapter

CHAPTER 9 OF 12 · Handle limits and failures

9. Keep serialized error records distinct

Back to contents

The short answer is that structured data sent across a network or stored as JSON is usually a record, not a live built-in Error object. Chapter 9 focuses on keep serialized error records distinct. Begin with the candidate value, its realm, ErrorData internal slot, local constructor and prototype chain, subclass brand, custom name and Symbol.toStringTag, proxy boundary, structured data fields and the operation the caller actually needs. Writing those facts first prevents a familiar label or final console line from replacing the operation that actually decides the result.

Worked example. Serialize selected name, message and code fields, parse them and observe Error.isError false. Treat every stated value as part of a controlled teaching fixture. Record the starting state before the call, then record each conversion, lookup, check or state transition in order. Stop the trace when an abrupt completion occurs; later effects are not inferred from what normally would have happened.

A useful first-principles question for keep serialized error records distinct is: what must already be true before this step can run? Use the rule above to separate the input contract from the result. Follow object identity, state and returned value independently. Two branches can print similar data while differing in ownership, timing, brand or future capability.

Now change exactly one premise. Reconstruct a new local Error deliberately and keep the original record as provenance. Recalculate the trace from the changed fact rather than editing the old conclusion. Name the earliest event that differs, carry that difference through the remaining steps, and say which observations stay the same because their prerequisites did not change.

The main limit is this: Reconstruction creates a new error identity and stack context; it does not recover the original object. Keep language semantics separate from processor strategy, host scheduling, browser support, trust policy and the meaning assigned by an application. A focused example can establish the stated mechanism without pretending to settle those broader questions.

Practical evidence check. Validate the record schema and mark reconstructed fields explicitly. Capture returned values and thrown error classes, but also preserve the event log that led to them. A test that asserts only the last value can pass even when an earlier conversion, constructor, iterator close, atomic operation or realm boundary was wrong.

A concise final explanation of keep serialized error records distinct should state the starting state, the governing rule, the ordered outcome and one boundary. It should not depend on a screenshot, engine message wording or an unstated timing assumption. That form is short enough for revision and precise enough for a code review or debugging note.

Contents · Previous chapter · Next chapter

CHAPTER 10 OF 12 · Handle limits and failures

10. Check availability before using a new method

Back to contents

The short answer is that a runtime may not yet expose Error.isError even when the specification feature is current. Chapter 10 focuses on check availability before using a new method. Begin with the candidate value, its realm, ErrorData internal slot, local constructor and prototype chain, subclass brand, custom name and Symbol.toStringTag, proxy boundary, structured data fields and the operation the caller actually needs. Writing those facts first prevents a familiar label or final console line from replacing the operation that actually decides the result.

Worked example. Test typeof Error.isError === ‘function’ before selecting the brand path. Treat every stated value as part of a controlled teaching fixture. Record the starting state before the call, then record each conversion, lookup, check or state transition in order. Stop the trace when an abrupt completion occurs; later effects are not inferred from what normally would have happened.

A useful first-principles question for check availability before using a new method is: what must already be true before this step can run? Use the rule above to separate the input contract from the result. Follow object identity, state and returned value independently. Two branches can print similar data while differing in ownership, timing, brand or future capability.

Now change exactly one premise. Use a documented fallback that states its narrower or different guarantees. Recalculate the trace from the changed fact rather than editing the old conclusion. Name the earliest event that differs, carry that difference through the remaining steps, and say which observations stay the same because their prerequisites did not change.

The main limit is this: A fallback based on instanceof or tags cannot honestly be advertised as the same cross-realm brand test. Keep language semantics separate from processor strategy, host scheduling, browser support, trust policy and the meaning assigned by an application. A focused example can establish the stated mechanism without pretending to settle those broader questions.

Practical evidence check. Include runtime version and feature detection in evidence. Capture returned values and thrown error classes, but also preserve the event log that led to them. A test that asserts only the last value can pass even when an earlier conversion, constructor, iterator close, atomic operation or realm boundary was wrong.

A concise final explanation of check availability before using a new method should state the starting state, the governing rule, the ordered outcome and one boundary. It should not depend on a screenshot, engine message wording or an unstated timing assumption. That form is short enough for revision and precise enough for a code review or debugging note.

Contents · Previous chapter · Next chapter

CHAPTER 11 OF 12 · Verify and explain

11. Choose the next operation, not a universal label

Back to contents

The short answer is that brand identity is only one input to decisions about reporting, retrying, security, user messages or transport. Chapter 11 focuses on choose the next operation, not a universal label. Begin with the candidate value, its realm, ErrorData internal slot, local constructor and prototype chain, subclass brand, custom name and Symbol.toStringTag, proxy boundary, structured data fields and the operation the caller actually needs. Writing those facts first prevents a familiar label or final console line from replacing the operation that actually decides the result.

Worked example. For a branded Error, extract a safe internal code under an application allowlist instead of displaying arbitrary message text. Treat every stated value as part of a controlled teaching fixture. Record the starting state before the call, then record each conversion, lookup, check or state transition in order. Stop the trace when an abrupt completion occurs; later effects are not inferred from what normally would have happened.

A useful first-principles question for choose the next operation, not a universal label is: what must already be true before this step can run? Use the rule above to separate the input contract from the result. Follow object identity, state and returned value independently. Two branches can print similar data while differing in ownership, timing, brand or future capability.

Now change exactly one premise. For a valid wire record, handle it even though Error.isError is false. Recalculate the trace from the changed fact rather than editing the old conclusion. Name the earliest event that differs, carry that difference through the remaining steps, and say which observations stay the same because their prerequisites did not change.

The main limit is this: Built-in branding is not an authorization, origin or sanitization check. Keep language semantics separate from processor strategy, host scheduling, browser support, trust policy and the meaning assigned by an application. A focused example can establish the stated mechanism without pretending to settle those broader questions.

Practical evidence check. Write separate policies for detection, classification and presentation. Capture returned values and thrown error classes, but also preserve the event log that led to them. A test that asserts only the last value can pass even when an earlier conversion, constructor, iterator close, atomic operation or realm boundary was wrong.

A concise final explanation of choose the next operation, not a universal label should state the starting state, the governing rule, the ordered outcome and one boundary. It should not depend on a screenshot, engine message wording or an unstated timing assumption. That form is short enough for revision and precise enough for a code review or debugging note.

Contents · Previous chapter · Next chapter

CHAPTER 12 OF 12 · Verify and explain

12. Explain realms, brands and records in order

Back to contents

The short answer is that a complete account names where the value was created, what brand predicate asks, what instanceof asks and what the application still must validate. Chapter 12 focuses on explain realms, brands and records in order. Begin with the candidate value, its realm, ErrorData internal slot, local constructor and prototype chain, subclass brand, custom name and Symbol.toStringTag, proxy boundary, structured data fields and the operation the caller actually needs. Writing those facts first prevents a familiar label or final console line from replacing the operation that actually decides the result.

Worked example. Report cross-realm Error.isError true and local instanceof Error false. Treat every stated value as part of a controlled teaching fixture. Record the starting state before the call, then record each conversion, lookup, check or state transition in order. Stop the trace when an abrupt completion occurs; later effects are not inferred from what normally would have happened.

A useful first-principles question for explain realms, brands and records in order is: what must already be true before this step can run? Use the rule above to separate the input contract from the result. Follow object identity, state and returned value independently. Two branches can print similar data while differing in ownership, timing, brand or future capability.

Now change exactly one premise. Change the candidate to a tagged look-alike and rebuild both results. Recalculate the trace from the changed fact rather than editing the old conclusion. Name the earliest event that differs, carry that difference through the remaining steps, and say which observations stay the same because their prerequisites did not change.

The main limit is this: Do not collapse internal branding, prototype membership and record validity into one word such as type. Keep language semantics separate from processor strategy, host scheduling, browser support, trust policy and the meaning assigned by an application. A focused example can establish the stated mechanism without pretending to settle those broader questions.

Practical evidence check. End with one decisive observation and one limit on the conclusion. Capture returned values and thrown error classes, but also preserve the event log that led to them. A test that asserts only the last value can pass even when an earlier conversion, constructor, iterator close, atomic operation or realm boundary was wrong.

A concise final explanation of explain realms, brands and records in order should state the starting state, the governing rule, the ordered outcome and one boundary. It should not depend on a screenshot, engine message wording or an unstated timing assumption. That form is short enough for revision and precise enough for a code review or debugging note.

Contents · Previous chapter · Return to the Websites subject guide

Frequently asked questions

What does Error.isError test?

It tests for the internal ErrorData slot used by built-in Error objects.

Why can instanceof fail across realms?

The value may not inherit from the current realm’s Error.prototype.

Do TypeError and AggregateError pass?

Yes, built-in native error instances carry the Error brand.

Can a plain object copy the brand?

No. Copying name, message, stack or toStringTag does not install the internal slot.

Does a true result make a message safe?

No. Presentation and trust checks remain application responsibilities.

What if Error.isError is unavailable?

Feature-detect it and document that any fallback answers a different or narrower question.

Continue through the verified reading routes

Start with the wider system

The Gold Standard of Websites · The Gold Standard of Education | Learning That Transfers into Life · How X Works hub

Compare the closest mechanisms

Object type tags versus verified runtime capabilities · Own property presence versus inherited lookup · Bound function calls and construction

Choose the next lesson by reader job

Use the subject root to move from this focused mechanism to the next verified question. Follow a specialist link when its preconditions match your code; return to the wider hub when the next task belongs to a different system.

Authoritative sources and evidence checks

TC39 Stage 4 draft: Error.isError · ECMAScript 2027: Error objects · ECMAScript 2027: instanceof operator · ECMAScript 2027: Object.prototype.toString

The ECMAScript specification defines the language algorithms. A cited proposal draft is used where it contains the integrated Stage 4 text. Controlled runtime checks can confirm an implementation’s current behaviour, but feature availability and performance still depend on the runtime version and environment.