When a learner can reproduce a familiar example but a small variation causes confusion, the problem is usually an incomplete model rather than a lack of effort. The fastest useful response is to expose the hidden state and test one boundary at a time.
JavaScript Object.hasOwn(object, key) answers one precise structural question: does the object itself have a property with this key? It does not read the property value, require enumerability, or search the prototype chain. The method converts ordinary keys to property keys, supports symbols, works with null-prototype objects and objects that shadow hasOwnProperty, distinguishes array holes from present undefined elements, and can trigger a proxy’s own-property machinery. Mastery means separating ownership from value, inheritance and enumeration, then using the check only where that distinction changes the program’s decision. This guide begins with that mechanism, then develops it through worked traces, deliberate mistakes, explained practice and transfer decisions.
The aim is independent reasoning. A learner should be able to predict behaviour, locate the earliest wrong assumption, use a safe diagnostic procedure and defend a design choice in a new project.
Punggol families can use the guide in short sessions around homework, CCAs and rest. The activities are proposed learning exercises, not claims about a physical branch, timetable, class size, fee, school relationship or guaranteed result.
Use disposable data and repositories, preserve backups, and check version-sensitive details against the official source. Current documentation settles a technical contract; observation and explanation turn that contract into usable knowledge.
Find your next learning step
Choose the route that matches the present difficulty. Use the complete index for a systematic course.
Build the model
Chapters 1-4 . Begin here, then continue after the learner can predict, verify and explain.
Use the core tools
Chapters 5-8 . Begin here, then continue after the learner can predict, verify and explain.
Handle boundaries
Chapters 9-12 . Begin here, then continue after the learner can predict, verify and explain.
Debug and verify
Chapters 13-16 . Begin here, then continue after the learner can predict, verify and explain.
Transfer with judgment
Chapters 17-20 . Begin here, then continue after the learner can predict, verify and explain.
Open the full chapter index . Jump to capstone practice . Use the How Studying Works hub . Read the official documentation
Complete chapter index
Chapters 1-4 . Build the model
Chapters 5-8 . Use the core tools
Chapters 9-12 . Handle boundaries
Chapters 13-16 . Debug and verify
Object.hasOwn returns true only when the receiver’s own property descriptor exists for the requested key. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is calling a readable inherited value an own record. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Own properties differ from inherited properties, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.
For the Own properties differ from inherited properties chapter on JavaScript Object.hasOwn(), use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on calling a readable inherited value an own record. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
const proto={shared:1}; const obj=Object.create(proto); obj.local=2;
console.log(Object.hasOwn(obj,'local'),Object.hasOwn(obj,'shared'));Explained result. local is true and shared is false because shared comes through the prototype. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: homework settings. Predict the rule using an explicit false or undefined choice is separated from an absent choice. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Object.hasOwn returns true only when the receiver’s own property descriptor exists for the requested key.” Apply this procedure: State the contract for Own properties differ from inherited properties, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: local is true and shared is false because shared comes through the prototype. For the homework settings, add one near-miss that exposes calling a readable inherited value an own record. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: reading tracker. Contrast the rule using own progress fields are distinguished from shared prototype methods. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Object.hasOwn returns true only when the receiver’s own property descriptor exists for the requested key.” Apply this procedure: State the contract for Own properties differ from inherited properties, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: local is true and shared is false because shared comes through the prototype. For the reading tracker, add one near-miss that exposes calling a readable inherited value an own record. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: science data. Stress-test the rule using a sparse measurement array separates holes from recorded undefined values. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Object.hasOwn returns true only when the receiver’s own property descriptor exists for the requested key.” Apply this procedure: State the contract for Own properties differ from inherited properties, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: local is true and shared is false because shared comes through the prototype. For the science data, add one near-miss that exposes calling a readable inherited value an own record. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: CCA form. Explain the rule using untrusted field names cannot disable an ownership test by shadowing hasOwnProperty. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Object.hasOwn returns true only when the receiver’s own property descriptor exists for the requested key.” Apply this procedure: State the contract for Own properties differ from inherited properties, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: local is true and shared is false because shared comes through the prototype. For the CCA form, add one near-miss that exposes calling a readable inherited value an own record. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers calling a readable inherited value an own record.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “State the contract for Own properties differ from inherited properties, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final JavaScript Object.hasOwn() syntax. For this chapter, useful prompts are: “What did you expect from Own properties differ from inherited properties?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing calling a readable inherited value an own record be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny library catalogue with null-prototype lookup tables are checked safely. Include one ordinary case, one boundary and one deliberate failure caused by calling a readable inherited value an own record. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: Object.hasOwn returns true only when the receiver’s own property descriptor exists for the requested key. It shows a trace, not only a final value. The ordinary case should demonstrate “local is true and shared is false because shared comes through the prototype.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Own properties differ from inherited properties, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For Own properties differ from inherited properties, separate the documented JavaScript Object.hasOwn() mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
CHAPTER 2 OF 20 . Build the model
2. A present undefined value is still an own property
Ownership depends on the descriptor, not on whether reading the value produces undefined. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is using obj[key] !== undefined to decide whether a field was supplied. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for A present undefined value is still an own property, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.
For the A present undefined value is still an own property chapter on JavaScript Object.hasOwn(), use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on using obj[key] !== undefined to decide whether a field was supplied. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
const obj={answer:undefined};
console.log(Object.hasOwn(obj,'answer'),Object.hasOwn(obj,'missing'));Explained result. answer is owned and true; missing has no descriptor and is false. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: science data. Contrast the rule using a sparse measurement array separates holes from recorded undefined values. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Ownership depends on the descriptor, not on whether reading the value produces undefined.” Apply this procedure: State the contract for A present undefined value is still an own property, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: answer is owned and true; missing has no descriptor and is false. For the science data, add one near-miss that exposes using obj[key] !== undefined to decide whether a field was supplied. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: CCA form. Stress-test the rule using untrusted field names cannot disable an ownership test by shadowing hasOwnProperty. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Ownership depends on the descriptor, not on whether reading the value produces undefined.” Apply this procedure: State the contract for A present undefined value is still an own property, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: answer is owned and true; missing has no descriptor and is false. For the CCA form, add one near-miss that exposes using obj[key] !== undefined to decide whether a field was supplied. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: family budget. Explain the rule using symbol metadata and non-enumerable state remain structurally visible. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Ownership depends on the descriptor, not on whether reading the value produces undefined.” Apply this procedure: State the contract for A present undefined value is still an own property, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: answer is owned and true; missing has no descriptor and is false. For the family budget, add one near-miss that exposes using obj[key] !== undefined to decide whether a field was supplied. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: library catalogue. Transfer the rule using null-prototype lookup tables are checked safely. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Ownership depends on the descriptor, not on whether reading the value produces undefined.” Apply this procedure: State the contract for A present undefined value is still an own property, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: answer is owned and true; missing has no descriptor and is false. For the library catalogue, add one near-miss that exposes using obj[key] !== undefined to decide whether a field was supplied. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers using obj[key] !== undefined to decide whether a field was supplied.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “State the contract for A present undefined value is still an own property, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final JavaScript Object.hasOwn() syntax. For this chapter, useful prompts are: “What did you expect from A present undefined value is still an own property?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing using obj[key] !== undefined to decide whether a field was supplied be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny test laboratory with inheritance, getters, proxies, arrays, primitives and coercion expose boundaries. Include one ordinary case, one boundary and one deliberate failure caused by using obj[key] !== undefined to decide whether a field was supplied. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: Ownership depends on the descriptor, not on whether reading the value produces undefined. It shows a trace, not only a final value. The ordinary case should demonstrate “answer is owned and true; missing has no descriptor and is false.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for A present undefined value is still an own property, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For A present undefined value is still an own property, separate the documented JavaScript Object.hasOwn() mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
Falsy values do not change ownership, so the method preserves meaningful explicit choices. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is using truthiness as a presence test for valid false, zero or empty values. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for False zero and empty text remain present, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.
For the False zero and empty text remain present chapter on JavaScript Object.hasOwn(), use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on using truthiness as a presence test for valid false, zero or empty values. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
const obj={done:false,count:0,note:''};
console.log(['done','count','note'].map(k=>Object.hasOwn(obj,k)));Explained result. All three results are true because each key exists on the object. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: family budget. Stress-test the rule using symbol metadata and non-enumerable state remain structurally visible. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Falsy values do not change ownership, so the method preserves meaningful explicit choices.” Apply this procedure: State the contract for False zero and empty text remain present, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: All three results are true because each key exists on the object. For the family budget, add one near-miss that exposes using truthiness as a presence test for valid false, zero or empty values. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: library catalogue. Explain the rule using null-prototype lookup tables are checked safely. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Falsy values do not change ownership, so the method preserves meaningful explicit choices.” Apply this procedure: State the contract for False zero and empty text remain present, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: All three results are true because each key exists on the object. For the library catalogue, add one near-miss that exposes using truthiness as a presence test for valid false, zero or empty values. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: test laboratory. Transfer the rule using inheritance, getters, proxies, arrays, primitives and coercion expose boundaries. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Falsy values do not change ownership, so the method preserves meaningful explicit choices.” Apply this procedure: State the contract for False zero and empty text remain present, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: All three results are true because each key exists on the object. For the test laboratory, add one near-miss that exposes using truthiness as a presence test for valid false, zero or empty values. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: design decision. Predict the rule using Object.hasOwn is compared with in, Object.keys, value checks and property descriptors. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Falsy values do not change ownership, so the method preserves meaningful explicit choices.” Apply this procedure: State the contract for False zero and empty text remain present, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: All three results are true because each key exists on the object. For the design decision, add one near-miss that exposes using truthiness as a presence test for valid false, zero or empty values. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers using truthiness as a presence test for valid false, zero or empty values.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “State the contract for False zero and empty text remain present, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final JavaScript Object.hasOwn() syntax. For this chapter, useful prompts are: “What did you expect from False zero and empty text remain present?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing using truthiness as a presence test for valid false, zero or empty values be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny design decision with Object.hasOwn is compared with in, Object.keys, value checks and property descriptors. Include one ordinary case, one boundary and one deliberate failure caused by using truthiness as a presence test for valid false, zero or empty values. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: Falsy values do not change ownership, so the method preserves meaningful explicit choices. It shows a trace, not only a final value. The ordinary case should demonstrate “All three results are true because each key exists on the object.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for False zero and empty text remain present, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For False zero and empty text remain present, separate the documented JavaScript Object.hasOwn() mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
Object.hasOwn does not require the property’s enumerable flag to be true. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is equating absence from Object.keys with absence from the object. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Non-enumerable properties still count as own, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.
For the Non-enumerable properties still count as own chapter on JavaScript Object.hasOwn(), use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on equating absence from Object.keys with absence from the object. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
const obj={}; Object.defineProperty(obj,'secret',{value:7,enumerable:false});
console.log(Object.keys(obj),Object.hasOwn(obj,'secret'));Explained result. Object.keys is empty, but Object.hasOwn returns true for secret. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: test laboratory. Explain the rule using inheritance, getters, proxies, arrays, primitives and coercion expose boundaries. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Object.hasOwn does not require the property’s enumerable flag to be true.” Apply this procedure: State the contract for Non-enumerable properties still count as own, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Object.keys is empty, but Object.hasOwn returns true for secret. For the test laboratory, add one near-miss that exposes equating absence from Object.keys with absence from the object. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: design decision. Transfer the rule using Object.hasOwn is compared with in, Object.keys, value checks and property descriptors. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Object.hasOwn does not require the property’s enumerable flag to be true.” Apply this procedure: State the contract for Non-enumerable properties still count as own, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Object.keys is empty, but Object.hasOwn returns true for secret. For the design decision, add one near-miss that exposes equating absence from Object.keys with absence from the object. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: homework settings. Predict the rule using an explicit false or undefined choice is separated from an absent choice. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Object.hasOwn does not require the property’s enumerable flag to be true.” Apply this procedure: State the contract for Non-enumerable properties still count as own, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Object.keys is empty, but Object.hasOwn returns true for secret. For the homework settings, add one near-miss that exposes equating absence from Object.keys with absence from the object. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: reading tracker. Contrast the rule using own progress fields are distinguished from shared prototype methods. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Object.hasOwn does not require the property’s enumerable flag to be true.” Apply this procedure: State the contract for Non-enumerable properties still count as own, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Object.keys is empty, but Object.hasOwn returns true for secret. For the reading tracker, add one near-miss that exposes equating absence from Object.keys with absence from the object. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers equating absence from Object.keys with absence from the object.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “State the contract for Non-enumerable properties still count as own, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final JavaScript Object.hasOwn() syntax. For this chapter, useful prompts are: “What did you expect from Non-enumerable properties still count as own?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing equating absence from Object.keys with absence from the object be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny homework settings with an explicit false or undefined choice is separated from an absent choice. Include one ordinary case, one boundary and one deliberate failure caused by equating absence from Object.keys with absence from the object. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: Object.hasOwn does not require the property’s enumerable flag to be true. It shows a trace, not only a final value. The ordinary case should demonstrate “Object.keys is empty, but Object.hasOwn returns true for secret.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Non-enumerable properties still count as own, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For Non-enumerable properties still count as own, separate the documented JavaScript Object.hasOwn() mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
ToPropertyKey preserves Symbols, so symbol-keyed own properties can be tested without converting them to strings. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is searching for a symbol description as though it were the property key. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Symbol keys are supported directly, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.
For the Symbol keys are supported directly chapter on JavaScript Object.hasOwn(), use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on searching for a symbol description as though it were the property key. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
const token=Symbol('token'); const obj={[token]:42};
console.log(Object.hasOwn(obj,token),Object.hasOwn(obj,'token'));Explained result. The symbol check is true and the string check is false because they are different keys. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: homework settings. Transfer the rule using an explicit false or undefined choice is separated from an absent choice. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “ToPropertyKey preserves Symbols, so symbol-keyed own properties can be tested without converting them to strings.” Apply this procedure: State the contract for Symbol keys are supported directly, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The symbol check is true and the string check is false because they are different keys. For the homework settings, add one near-miss that exposes searching for a symbol description as though it were the property key. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: reading tracker. Predict the rule using own progress fields are distinguished from shared prototype methods. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “ToPropertyKey preserves Symbols, so symbol-keyed own properties can be tested without converting them to strings.” Apply this procedure: State the contract for Symbol keys are supported directly, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The symbol check is true and the string check is false because they are different keys. For the reading tracker, add one near-miss that exposes searching for a symbol description as though it were the property key. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: science data. Contrast the rule using a sparse measurement array separates holes from recorded undefined values. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “ToPropertyKey preserves Symbols, so symbol-keyed own properties can be tested without converting them to strings.” Apply this procedure: State the contract for Symbol keys are supported directly, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The symbol check is true and the string check is false because they are different keys. For the science data, add one near-miss that exposes searching for a symbol description as though it were the property key. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: CCA form. Stress-test the rule using untrusted field names cannot disable an ownership test by shadowing hasOwnProperty. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “ToPropertyKey preserves Symbols, so symbol-keyed own properties can be tested without converting them to strings.” Apply this procedure: State the contract for Symbol keys are supported directly, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The symbol check is true and the string check is false because they are different keys. For the CCA form, add one near-miss that exposes searching for a symbol description as though it were the property key. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers searching for a symbol description as though it were the property key.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “State the contract for Symbol keys are supported directly, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final JavaScript Object.hasOwn() syntax. For this chapter, useful prompts are: “What did you expect from Symbol keys are supported directly?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing searching for a symbol description as though it were the property key be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny reading tracker with own progress fields are distinguished from shared prototype methods. Include one ordinary case, one boundary and one deliberate failure caused by searching for a symbol description as though it were the property key. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: ToPropertyKey preserves Symbols, so symbol-keyed own properties can be tested without converting them to strings. It shows a trace, not only a final value. The ordinary case should demonstrate “The symbol check is true and the string check is false because they are different keys.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Symbol keys are supported directly, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For Symbol keys are supported directly, separate the documented JavaScript Object.hasOwn() mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
ToPropertyKey converts a numeric key to its string property-key form for an ordinary object. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is believing object keys retain a separate numeric identity. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Ordinary numeric keys become strings, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.
For the Ordinary numeric keys become strings chapter on JavaScript Object.hasOwn(), use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on believing object keys retain a separate numeric identity. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
const obj={'2':'two'};
console.log(Object.hasOwn(obj,2),Object.hasOwn(obj,'2'));Explained result. Both checks are true because numeric 2 converts to the string key 2. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: science data. Predict the rule using a sparse measurement array separates holes from recorded undefined values. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “ToPropertyKey converts a numeric key to its string property-key form for an ordinary object.” Apply this procedure: State the contract for Ordinary numeric keys become strings, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Both checks are true because numeric 2 converts to the string key 2. For the science data, add one near-miss that exposes believing object keys retain a separate numeric identity. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: CCA form. Contrast the rule using untrusted field names cannot disable an ownership test by shadowing hasOwnProperty. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “ToPropertyKey converts a numeric key to its string property-key form for an ordinary object.” Apply this procedure: State the contract for Ordinary numeric keys become strings, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Both checks are true because numeric 2 converts to the string key 2. For the CCA form, add one near-miss that exposes believing object keys retain a separate numeric identity. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: family budget. Stress-test the rule using symbol metadata and non-enumerable state remain structurally visible. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “ToPropertyKey converts a numeric key to its string property-key form for an ordinary object.” Apply this procedure: State the contract for Ordinary numeric keys become strings, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Both checks are true because numeric 2 converts to the string key 2. For the family budget, add one near-miss that exposes believing object keys retain a separate numeric identity. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: library catalogue. Explain the rule using null-prototype lookup tables are checked safely. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “ToPropertyKey converts a numeric key to its string property-key form for an ordinary object.” Apply this procedure: State the contract for Ordinary numeric keys become strings, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Both checks are true because numeric 2 converts to the string key 2. For the library catalogue, add one near-miss that exposes believing object keys retain a separate numeric identity. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers believing object keys retain a separate numeric identity.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “State the contract for Ordinary numeric keys become strings, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final JavaScript Object.hasOwn() syntax. For this chapter, useful prompts are: “What did you expect from Ordinary numeric keys become strings?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing believing object keys retain a separate numeric identity be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny science data with a sparse measurement array separates holes from recorded undefined values. Include one ordinary case, one boundary and one deliberate failure caused by believing object keys retain a separate numeric identity. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: ToPropertyKey converts a numeric key to its string property-key form for an ordinary object. It shows a trace, not only a final value. The ordinary case should demonstrate “Both checks are true because numeric 2 converts to the string key 2.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Ordinary numeric keys become strings, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For Ordinary numeric keys become strings, separate the documented JavaScript Object.hasOwn() mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
CHAPTER 7 OF 20 . Use the core tools
7. Array indexes are own properties when present
A populated array index is an own property of the array object. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is treating every index below length as automatically present. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Array indexes are own properties when present, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.
For the Array indexes are own properties when present chapter on JavaScript Object.hasOwn(), use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on treating every index below length as automatically present. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
const a=['x'];
console.log(Object.hasOwn(a,0),Object.hasOwn(a,1));Explained result. Index 0 is owned, while index 1 is absent. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: family budget. Contrast the rule using symbol metadata and non-enumerable state remain structurally visible. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “A populated array index is an own property of the array object.” Apply this procedure: State the contract for Array indexes are own properties when present, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Index 0 is owned, while index 1 is absent. For the family budget, add one near-miss that exposes treating every index below length as automatically present. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: library catalogue. Stress-test the rule using null-prototype lookup tables are checked safely. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “A populated array index is an own property of the array object.” Apply this procedure: State the contract for Array indexes are own properties when present, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Index 0 is owned, while index 1 is absent. For the library catalogue, add one near-miss that exposes treating every index below length as automatically present. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: test laboratory. Explain the rule using inheritance, getters, proxies, arrays, primitives and coercion expose boundaries. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “A populated array index is an own property of the array object.” Apply this procedure: State the contract for Array indexes are own properties when present, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Index 0 is owned, while index 1 is absent. For the test laboratory, add one near-miss that exposes treating every index below length as automatically present. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: design decision. Transfer the rule using Object.hasOwn is compared with in, Object.keys, value checks and property descriptors. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “A populated array index is an own property of the array object.” Apply this procedure: State the contract for Array indexes are own properties when present, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Index 0 is owned, while index 1 is absent. For the design decision, add one near-miss that exposes treating every index below length as automatically present. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers treating every index below length as automatically present.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “State the contract for Array indexes are own properties when present, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final JavaScript Object.hasOwn() syntax. For this chapter, useful prompts are: “What did you expect from Array indexes are own properties when present?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing treating every index below length as automatically present be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny CCA form with untrusted field names cannot disable an ownership test by shadowing hasOwnProperty. Include one ordinary case, one boundary and one deliberate failure caused by treating every index below length as automatically present. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: A populated array index is an own property of the array object. It shows a trace, not only a final value. The ordinary case should demonstrate “Index 0 is owned, while index 1 is absent.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Array indexes are own properties when present, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For Array indexes are own properties when present, separate the documented JavaScript Object.hasOwn() mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
A hole lacks an own index descriptor, whereas assigning undefined creates a present own index. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is printing both as undefined and declaring the structures identical. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Array holes differ from undefined elements, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.
For the Array holes differ from undefined elements chapter on JavaScript Object.hasOwn(), use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on printing both as undefined and declaring the structures identical. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
const a=new Array(2); a[1]=undefined;
console.log(Object.hasOwn(a,0),Object.hasOwn(a,1));Explained result. The hole at 0 is false and the explicit undefined at 1 is true. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: test laboratory. Stress-test the rule using inheritance, getters, proxies, arrays, primitives and coercion expose boundaries. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “A hole lacks an own index descriptor, whereas assigning undefined creates a present own index.” Apply this procedure: State the contract for Array holes differ from undefined elements, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The hole at 0 is false and the explicit undefined at 1 is true. For the test laboratory, add one near-miss that exposes printing both as undefined and declaring the structures identical. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: design decision. Explain the rule using Object.hasOwn is compared with in, Object.keys, value checks and property descriptors. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “A hole lacks an own index descriptor, whereas assigning undefined creates a present own index.” Apply this procedure: State the contract for Array holes differ from undefined elements, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The hole at 0 is false and the explicit undefined at 1 is true. For the design decision, add one near-miss that exposes printing both as undefined and declaring the structures identical. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: homework settings. Transfer the rule using an explicit false or undefined choice is separated from an absent choice. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “A hole lacks an own index descriptor, whereas assigning undefined creates a present own index.” Apply this procedure: State the contract for Array holes differ from undefined elements, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The hole at 0 is false and the explicit undefined at 1 is true. For the homework settings, add one near-miss that exposes printing both as undefined and declaring the structures identical. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: reading tracker. Predict the rule using own progress fields are distinguished from shared prototype methods. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “A hole lacks an own index descriptor, whereas assigning undefined creates a present own index.” Apply this procedure: State the contract for Array holes differ from undefined elements, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The hole at 0 is false and the explicit undefined at 1 is true. For the reading tracker, add one near-miss that exposes printing both as undefined and declaring the structures identical. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers printing both as undefined and declaring the structures identical.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “State the contract for Array holes differ from undefined elements, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final JavaScript Object.hasOwn() syntax. For this chapter, useful prompts are: “What did you expect from Array holes differ from undefined elements?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing printing both as undefined and declaring the structures identical be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny family budget with symbol metadata and non-enumerable state remain structurally visible. Include one ordinary case, one boundary and one deliberate failure caused by printing both as undefined and declaring the structures identical. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: A hole lacks an own index descriptor, whereas assigning undefined creates a present own index. It shows a trace, not only a final value. The ordinary case should demonstrate “The hole at 0 is false and the explicit undefined at 1 is true.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Array holes differ from undefined elements, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For Array holes differ from undefined elements, separate the documented JavaScript Object.hasOwn() mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
Every array has an own length property even though Object.keys does not list it. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is using enumerable indexes as a complete picture of array ownership. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Array length is a non-enumerable own property, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.
For the Array length is a non-enumerable own property chapter on JavaScript Object.hasOwn(), use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on using enumerable indexes as a complete picture of array ownership. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
const a=['x','y'];
console.log(Object.hasOwn(a,'length'),Object.keys(a));Explained result. length is owned, while Object.keys lists only the enumerable indexes. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: homework settings. Explain the rule using an explicit false or undefined choice is separated from an absent choice. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Every array has an own length property even though Object.keys does not list it.” Apply this procedure: State the contract for Array length is a non-enumerable own property, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: length is owned, while Object.keys lists only the enumerable indexes. For the homework settings, add one near-miss that exposes using enumerable indexes as a complete picture of array ownership. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: reading tracker. Transfer the rule using own progress fields are distinguished from shared prototype methods. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Every array has an own length property even though Object.keys does not list it.” Apply this procedure: State the contract for Array length is a non-enumerable own property, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: length is owned, while Object.keys lists only the enumerable indexes. For the reading tracker, add one near-miss that exposes using enumerable indexes as a complete picture of array ownership. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: science data. Predict the rule using a sparse measurement array separates holes from recorded undefined values. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Every array has an own length property even though Object.keys does not list it.” Apply this procedure: State the contract for Array length is a non-enumerable own property, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: length is owned, while Object.keys lists only the enumerable indexes. For the science data, add one near-miss that exposes using enumerable indexes as a complete picture of array ownership. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: CCA form. Contrast the rule using untrusted field names cannot disable an ownership test by shadowing hasOwnProperty. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Every array has an own length property even though Object.keys does not list it.” Apply this procedure: State the contract for Array length is a non-enumerable own property, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: length is owned, while Object.keys lists only the enumerable indexes. For the CCA form, add one near-miss that exposes using enumerable indexes as a complete picture of array ownership. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers using enumerable indexes as a complete picture of array ownership.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “State the contract for Array length is a non-enumerable own property, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final JavaScript Object.hasOwn() syntax. For this chapter, useful prompts are: “What did you expect from Array length is a non-enumerable own property?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing using enumerable indexes as a complete picture of array ownership be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny library catalogue with null-prototype lookup tables are checked safely. Include one ordinary case, one boundary and one deliberate failure caused by using enumerable indexes as a complete picture of array ownership. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: Every array has an own length property even though Object.keys does not list it. It shows a trace, not only a final value. The ordinary case should demonstrate “length is owned, while Object.keys lists only the enumerable indexes.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Array length is a non-enumerable own property, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For Array length is a non-enumerable own property, separate the documented JavaScript Object.hasOwn() mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
The static method does not depend on the receiver inheriting Object.prototype.hasOwnProperty. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is calling table.hasOwnProperty on an object deliberately created without a prototype. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Null-prototype objects are handled safely, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.
For the Null-prototype objects are handled safely chapter on JavaScript Object.hasOwn(), use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on calling table.hasOwnProperty on an object deliberately created without a prototype. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
const table=Object.create(null); table.ready=true;
console.log(Object.hasOwn(table,'ready'));Explained result. The result is true without requiring any inherited method. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: science data. Transfer the rule using a sparse measurement array separates holes from recorded undefined values. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “The static method does not depend on the receiver inheriting Object.prototype.hasOwnProperty.” Apply this procedure: State the contract for Null-prototype objects are handled safely, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The result is true without requiring any inherited method. For the science data, add one near-miss that exposes calling table.hasOwnProperty on an object deliberately created without a prototype. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: CCA form. Predict the rule using untrusted field names cannot disable an ownership test by shadowing hasOwnProperty. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “The static method does not depend on the receiver inheriting Object.prototype.hasOwnProperty.” Apply this procedure: State the contract for Null-prototype objects are handled safely, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The result is true without requiring any inherited method. For the CCA form, add one near-miss that exposes calling table.hasOwnProperty on an object deliberately created without a prototype. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: family budget. Contrast the rule using symbol metadata and non-enumerable state remain structurally visible. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “The static method does not depend on the receiver inheriting Object.prototype.hasOwnProperty.” Apply this procedure: State the contract for Null-prototype objects are handled safely, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The result is true without requiring any inherited method. For the family budget, add one near-miss that exposes calling table.hasOwnProperty on an object deliberately created without a prototype. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: library catalogue. Stress-test the rule using null-prototype lookup tables are checked safely. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “The static method does not depend on the receiver inheriting Object.prototype.hasOwnProperty.” Apply this procedure: State the contract for Null-prototype objects are handled safely, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The result is true without requiring any inherited method. For the library catalogue, add one near-miss that exposes calling table.hasOwnProperty on an object deliberately created without a prototype. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers calling table.hasOwnProperty on an object deliberately created without a prototype.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “State the contract for Null-prototype objects are handled safely, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final JavaScript Object.hasOwn() syntax. For this chapter, useful prompts are: “What did you expect from Null-prototype objects are handled safely?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing calling table.hasOwnProperty on an object deliberately created without a prototype be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny test laboratory with inheritance, getters, proxies, arrays, primitives and coercion expose boundaries. Include one ordinary case, one boundary and one deliberate failure caused by calling table.hasOwnProperty on an object deliberately created without a prototype. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: The static method does not depend on the receiver inheriting Object.prototype.hasOwnProperty. It shows a trace, not only a final value. The ordinary case should demonstrate “The result is true without requiring any inherited method.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Null-prototype objects are handled safely, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For Null-prototype objects are handled safely, separate the documented JavaScript Object.hasOwn() mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
CHAPTER 11 OF 20 . Handle boundaries
11. Shadowing hasOwnProperty cannot disable the static test
An own data property named hasOwnProperty does not affect Object.hasOwn. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is invoking user-controlled obj.hasOwnProperty and receiving a non-function or deceptive function. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Shadowing hasOwnProperty cannot disable the static test, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.
For the Shadowing hasOwnProperty cannot disable the static test chapter on JavaScript Object.hasOwn(), use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on invoking user-controlled obj.hasOwnProperty and receiving a non-function or deceptive function. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
const obj={hasOwnProperty:false,ready:true};
console.log(Object.hasOwn(obj,'ready'));Explained result. The static method returns true even though the object shadows the familiar method name. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: family budget. Predict the rule using symbol metadata and non-enumerable state remain structurally visible. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “An own data property named hasOwnProperty does not affect Object.hasOwn.” Apply this procedure: State the contract for Shadowing hasOwnProperty cannot disable the static test, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The static method returns true even though the object shadows the familiar method name. For the family budget, add one near-miss that exposes invoking user-controlled obj.hasOwnProperty and receiving a non-function or deceptive function. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: library catalogue. Contrast the rule using null-prototype lookup tables are checked safely. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “An own data property named hasOwnProperty does not affect Object.hasOwn.” Apply this procedure: State the contract for Shadowing hasOwnProperty cannot disable the static test, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The static method returns true even though the object shadows the familiar method name. For the library catalogue, add one near-miss that exposes invoking user-controlled obj.hasOwnProperty and receiving a non-function or deceptive function. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: test laboratory. Stress-test the rule using inheritance, getters, proxies, arrays, primitives and coercion expose boundaries. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “An own data property named hasOwnProperty does not affect Object.hasOwn.” Apply this procedure: State the contract for Shadowing hasOwnProperty cannot disable the static test, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The static method returns true even though the object shadows the familiar method name. For the test laboratory, add one near-miss that exposes invoking user-controlled obj.hasOwnProperty and receiving a non-function or deceptive function. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: design decision. Explain the rule using Object.hasOwn is compared with in, Object.keys, value checks and property descriptors. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “An own data property named hasOwnProperty does not affect Object.hasOwn.” Apply this procedure: State the contract for Shadowing hasOwnProperty cannot disable the static test, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The static method returns true even though the object shadows the familiar method name. For the design decision, add one near-miss that exposes invoking user-controlled obj.hasOwnProperty and receiving a non-function or deceptive function. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers invoking user-controlled obj.hasOwnProperty and receiving a non-function or deceptive function.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “State the contract for Shadowing hasOwnProperty cannot disable the static test, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final JavaScript Object.hasOwn() syntax. For this chapter, useful prompts are: “What did you expect from Shadowing hasOwnProperty cannot disable the static test?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing invoking user-controlled obj.hasOwnProperty and receiving a non-function or deceptive function be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny design decision with Object.hasOwn is compared with in, Object.keys, value checks and property descriptors. Include one ordinary case, one boundary and one deliberate failure caused by invoking user-controlled obj.hasOwnProperty and receiving a non-function or deceptive function. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: An own data property named hasOwnProperty does not affect Object.hasOwn. It shows a trace, not only a final value. The ordinary case should demonstrate “The static method returns true even though the object shadows the familiar method name.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Shadowing hasOwnProperty cannot disable the static test, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For Shadowing hasOwnProperty cannot disable the static test, separate the documented JavaScript Object.hasOwn() mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
Object.hasOwn begins with ToObject, which throws TypeError for null and undefined. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is using the method as an optional-access operator without guarding a missing receiver. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Null and undefined receivers throw, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.
For the Null and undefined receivers throw chapter on JavaScript Object.hasOwn(), use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on using the method as an optional-access operator without guarding a missing receiver. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
for(const value of [null,undefined]){ try{Object.hasOwn(value,'x')}catch(e){console.log(e.name)} }Explained result. Each call reports TypeError; guard the receiver when absence is permitted. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: test laboratory. Contrast the rule using inheritance, getters, proxies, arrays, primitives and coercion expose boundaries. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Object.hasOwn begins with ToObject, which throws TypeError for null and undefined.” Apply this procedure: State the contract for Null and undefined receivers throw, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Each call reports TypeError; guard the receiver when absence is permitted. For the test laboratory, add one near-miss that exposes using the method as an optional-access operator without guarding a missing receiver. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: design decision. Stress-test the rule using Object.hasOwn is compared with in, Object.keys, value checks and property descriptors. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Object.hasOwn begins with ToObject, which throws TypeError for null and undefined.” Apply this procedure: State the contract for Null and undefined receivers throw, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Each call reports TypeError; guard the receiver when absence is permitted. For the design decision, add one near-miss that exposes using the method as an optional-access operator without guarding a missing receiver. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: homework settings. Explain the rule using an explicit false or undefined choice is separated from an absent choice. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Object.hasOwn begins with ToObject, which throws TypeError for null and undefined.” Apply this procedure: State the contract for Null and undefined receivers throw, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Each call reports TypeError; guard the receiver when absence is permitted. For the homework settings, add one near-miss that exposes using the method as an optional-access operator without guarding a missing receiver. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: reading tracker. Transfer the rule using own progress fields are distinguished from shared prototype methods. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Object.hasOwn begins with ToObject, which throws TypeError for null and undefined.” Apply this procedure: State the contract for Null and undefined receivers throw, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Each call reports TypeError; guard the receiver when absence is permitted. For the reading tracker, add one near-miss that exposes using the method as an optional-access operator without guarding a missing receiver. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers using the method as an optional-access operator without guarding a missing receiver.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “State the contract for Null and undefined receivers throw, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final JavaScript Object.hasOwn() syntax. For this chapter, useful prompts are: “What did you expect from Null and undefined receivers throw?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing using the method as an optional-access operator without guarding a missing receiver be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny homework settings with an explicit false or undefined choice is separated from an absent choice. Include one ordinary case, one boundary and one deliberate failure caused by using the method as an optional-access operator without guarding a missing receiver. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: Object.hasOwn begins with ToObject, which throws TypeError for null and undefined. It shows a trace, not only a final value. The ordinary case should demonstrate “Each call reports TypeError; guard the receiver when absence is permitted.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Null and undefined receivers throw, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For Null and undefined receivers throw, separate the documented JavaScript Object.hasOwn() mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
ToObject wraps non-null primitives, allowing checks against their temporary object view. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is assuming every primitive receiver throws. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Other primitives are boxed for the check, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.
For the Other primitives are boxed for the check chapter on JavaScript Object.hasOwn(), use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on assuming every primitive receiver throws. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
console.log(Object.hasOwn('cat',0),Object.hasOwn(7,'toString'));Explained result. The string owns indexed character 0 in its boxed view; the number does not own inherited toString. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: homework settings. Stress-test the rule using an explicit false or undefined choice is separated from an absent choice. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “ToObject wraps non-null primitives, allowing checks against their temporary object view.” Apply this procedure: State the contract for Other primitives are boxed for the check, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The string owns indexed character 0 in its boxed view; the number does not own inherited toString. For the homework settings, add one near-miss that exposes assuming every primitive receiver throws. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: reading tracker. Explain the rule using own progress fields are distinguished from shared prototype methods. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “ToObject wraps non-null primitives, allowing checks against their temporary object view.” Apply this procedure: State the contract for Other primitives are boxed for the check, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The string owns indexed character 0 in its boxed view; the number does not own inherited toString. For the reading tracker, add one near-miss that exposes assuming every primitive receiver throws. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: science data. Transfer the rule using a sparse measurement array separates holes from recorded undefined values. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “ToObject wraps non-null primitives, allowing checks against their temporary object view.” Apply this procedure: State the contract for Other primitives are boxed for the check, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The string owns indexed character 0 in its boxed view; the number does not own inherited toString. For the science data, add one near-miss that exposes assuming every primitive receiver throws. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: CCA form. Predict the rule using untrusted field names cannot disable an ownership test by shadowing hasOwnProperty. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “ToObject wraps non-null primitives, allowing checks against their temporary object view.” Apply this procedure: State the contract for Other primitives are boxed for the check, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The string owns indexed character 0 in its boxed view; the number does not own inherited toString. For the CCA form, add one near-miss that exposes assuming every primitive receiver throws. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers assuming every primitive receiver throws.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “State the contract for Other primitives are boxed for the check, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final JavaScript Object.hasOwn() syntax. For this chapter, useful prompts are: “What did you expect from Other primitives are boxed for the check?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing assuming every primitive receiver throws be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny reading tracker with own progress fields are distinguished from shared prototype methods. Include one ordinary case, one boundary and one deliberate failure caused by assuming every primitive receiver throws. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: ToObject wraps non-null primitives, allowing checks against their temporary object view. It shows a trace, not only a final value. The ordinary case should demonstrate “The string owns indexed character 0 in its boxed view; the number does not own inherited toString.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Other primitives are boxed for the check, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For Other primitives are boxed for the check, separate the documented JavaScript Object.hasOwn() mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
CHAPTER 14 OF 20 . Debug and verify
14. An own accessor counts without calling its getter
HasOwnProperty asks for an own property descriptor and does not perform an ordinary value Get. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is expecting an ownership check to execute the accessor body. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for An own accessor counts without calling its getter, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.
For the An own accessor counts without calling its getter chapter on JavaScript Object.hasOwn(), use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on expecting an ownership check to execute the accessor body. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
let reads=0; const obj={get answer(){reads++;return 42}};
console.log(Object.hasOwn(obj,'answer'),reads);Explained result. The result is true and reads remains zero because the getter value was not requested. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: science data. Explain the rule using a sparse measurement array separates holes from recorded undefined values. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “HasOwnProperty asks for an own property descriptor and does not perform an ordinary value Get.” Apply this procedure: State the contract for An own accessor counts without calling its getter, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The result is true and reads remains zero because the getter value was not requested. For the science data, add one near-miss that exposes expecting an ownership check to execute the accessor body. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: CCA form. Transfer the rule using untrusted field names cannot disable an ownership test by shadowing hasOwnProperty. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “HasOwnProperty asks for an own property descriptor and does not perform an ordinary value Get.” Apply this procedure: State the contract for An own accessor counts without calling its getter, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The result is true and reads remains zero because the getter value was not requested. For the CCA form, add one near-miss that exposes expecting an ownership check to execute the accessor body. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: family budget. Predict the rule using symbol metadata and non-enumerable state remain structurally visible. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “HasOwnProperty asks for an own property descriptor and does not perform an ordinary value Get.” Apply this procedure: State the contract for An own accessor counts without calling its getter, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The result is true and reads remains zero because the getter value was not requested. For the family budget, add one near-miss that exposes expecting an ownership check to execute the accessor body. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: library catalogue. Contrast the rule using null-prototype lookup tables are checked safely. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “HasOwnProperty asks for an own property descriptor and does not perform an ordinary value Get.” Apply this procedure: State the contract for An own accessor counts without calling its getter, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The result is true and reads remains zero because the getter value was not requested. For the library catalogue, add one near-miss that exposes expecting an ownership check to execute the accessor body. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers expecting an ownership check to execute the accessor body.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “State the contract for An own accessor counts without calling its getter, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final JavaScript Object.hasOwn() syntax. For this chapter, useful prompts are: “What did you expect from An own accessor counts without calling its getter?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing expecting an ownership check to execute the accessor body be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny science data with a sparse measurement array separates holes from recorded undefined values. Include one ordinary case, one boundary and one deliberate failure caused by expecting an ownership check to execute the accessor body. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: HasOwnProperty asks for an own property descriptor and does not perform an ordinary value Get. It shows a trace, not only a final value. The ordinary case should demonstrate “The result is true and reads remains zero because the getter value was not requested.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for An own accessor counts without calling its getter, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For An own accessor counts without calling its getter, separate the documented JavaScript Object.hasOwn() mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
CHAPTER 15 OF 20 . Debug and verify
15. Class fields and prototype methods have different ownership
Instance fields are commonly own properties, while methods declared in a class body live on the prototype. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is checking an instance method with Object.hasOwn and concluding it is unavailable. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Class fields and prototype methods have different ownership, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.
For the Class fields and prototype methods have different ownership chapter on JavaScript Object.hasOwn(), use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on checking an instance method with Object.hasOwn and concluding it is unavailable. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
class Task{done=false; finish(){this.done=true}} const t=new Task();
console.log(Object.hasOwn(t,'done'),Object.hasOwn(t,'finish'),'finish' in t);Explained result. done is own, finish is inherited, and the in operator still finds finish. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: family budget. Transfer the rule using symbol metadata and non-enumerable state remain structurally visible. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Instance fields are commonly own properties, while methods declared in a class body live on the prototype.” Apply this procedure: State the contract for Class fields and prototype methods have different ownership, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: done is own, finish is inherited, and the in operator still finds finish. For the family budget, add one near-miss that exposes checking an instance method with Object.hasOwn and concluding it is unavailable. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: library catalogue. Predict the rule using null-prototype lookup tables are checked safely. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Instance fields are commonly own properties, while methods declared in a class body live on the prototype.” Apply this procedure: State the contract for Class fields and prototype methods have different ownership, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: done is own, finish is inherited, and the in operator still finds finish. For the library catalogue, add one near-miss that exposes checking an instance method with Object.hasOwn and concluding it is unavailable. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: test laboratory. Contrast the rule using inheritance, getters, proxies, arrays, primitives and coercion expose boundaries. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Instance fields are commonly own properties, while methods declared in a class body live on the prototype.” Apply this procedure: State the contract for Class fields and prototype methods have different ownership, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: done is own, finish is inherited, and the in operator still finds finish. For the test laboratory, add one near-miss that exposes checking an instance method with Object.hasOwn and concluding it is unavailable. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: design decision. Stress-test the rule using Object.hasOwn is compared with in, Object.keys, value checks and property descriptors. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Instance fields are commonly own properties, while methods declared in a class body live on the prototype.” Apply this procedure: State the contract for Class fields and prototype methods have different ownership, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: done is own, finish is inherited, and the in operator still finds finish. For the design decision, add one near-miss that exposes checking an instance method with Object.hasOwn and concluding it is unavailable. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers checking an instance method with Object.hasOwn and concluding it is unavailable.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “State the contract for Class fields and prototype methods have different ownership, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final JavaScript Object.hasOwn() syntax. For this chapter, useful prompts are: “What did you expect from Class fields and prototype methods have different ownership?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing checking an instance method with Object.hasOwn and concluding it is unavailable be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny CCA form with untrusted field names cannot disable an ownership test by shadowing hasOwnProperty. Include one ordinary case, one boundary and one deliberate failure caused by checking an instance method with Object.hasOwn and concluding it is unavailable. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: Instance fields are commonly own properties, while methods declared in a class body live on the prototype. It shows a trace, not only a final value. The ordinary case should demonstrate “done is own, finish is inherited, and the in operator still finds finish.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Class fields and prototype methods have different ownership, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For Class fields and prototype methods have different ownership, separate the documented JavaScript Object.hasOwn() mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
key in object answers whether an own or inherited property is available; Object.hasOwn narrows the answer to direct ownership. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is swapping the two tests without revisiting the data contract. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for The in operator includes the prototype chain, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.
For the The in operator includes the prototype chain chapter on JavaScript Object.hasOwn(), use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on swapping the two tests without revisiting the data contract. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
const obj=Object.create({shared:1});
console.log('shared' in obj,Object.hasOwn(obj,'shared'));Explained result. in returns true while Object.hasOwn returns false. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: test laboratory. Predict the rule using inheritance, getters, proxies, arrays, primitives and coercion expose boundaries. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “key in object answers whether an own or inherited property is available; Object.hasOwn narrows the answer to direct ownership.” Apply this procedure: State the contract for The in operator includes the prototype chain, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: in returns true while Object.hasOwn returns false. For the test laboratory, add one near-miss that exposes swapping the two tests without revisiting the data contract. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: design decision. Contrast the rule using Object.hasOwn is compared with in, Object.keys, value checks and property descriptors. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “key in object answers whether an own or inherited property is available; Object.hasOwn narrows the answer to direct ownership.” Apply this procedure: State the contract for The in operator includes the prototype chain, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: in returns true while Object.hasOwn returns false. For the design decision, add one near-miss that exposes swapping the two tests without revisiting the data contract. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: homework settings. Stress-test the rule using an explicit false or undefined choice is separated from an absent choice. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “key in object answers whether an own or inherited property is available; Object.hasOwn narrows the answer to direct ownership.” Apply this procedure: State the contract for The in operator includes the prototype chain, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: in returns true while Object.hasOwn returns false. For the homework settings, add one near-miss that exposes swapping the two tests without revisiting the data contract. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: reading tracker. Explain the rule using own progress fields are distinguished from shared prototype methods. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “key in object answers whether an own or inherited property is available; Object.hasOwn narrows the answer to direct ownership.” Apply this procedure: State the contract for The in operator includes the prototype chain, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: in returns true while Object.hasOwn returns false. For the reading tracker, add one near-miss that exposes swapping the two tests without revisiting the data contract. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers swapping the two tests without revisiting the data contract.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “State the contract for The in operator includes the prototype chain, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final JavaScript Object.hasOwn() syntax. For this chapter, useful prompts are: “What did you expect from The in operator includes the prototype chain?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing swapping the two tests without revisiting the data contract be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny family budget with symbol metadata and non-enumerable state remain structurally visible. Include one ordinary case, one boundary and one deliberate failure caused by swapping the two tests without revisiting the data contract. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: key in object answers whether an own or inherited property is available; Object.hasOwn narrows the answer to direct ownership. It shows a trace, not only a final value. The ordinary case should demonstrate “in returns true while Object.hasOwn returns false.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for The in operator includes the prototype chain, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For The in operator includes the prototype chain, separate the documented JavaScript Object.hasOwn() mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
CHAPTER 17 OF 20 . Transfer with judgment
17. Object.keys applies an enumerable string filter
Object.keys lists enumerable own string keys, whereas Object.hasOwn can test one non-enumerable or symbol key. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is building a full key list merely to ask one ownership question. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Object.keys applies an enumerable string filter, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.
For the Object.keys applies an enumerable string filter chapter on JavaScript Object.hasOwn(), use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on building a full key list merely to ask one ownership question. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
const obj={a:1}; Object.defineProperty(obj,'b',{value:2});
console.log(Object.keys(obj),Object.hasOwn(obj,'b'));Explained result. The list contains a only, while the targeted test finds b. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: homework settings. Contrast the rule using an explicit false or undefined choice is separated from an absent choice. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Object.keys lists enumerable own string keys, whereas Object.hasOwn can test one non-enumerable or symbol key.” Apply this procedure: State the contract for Object.keys applies an enumerable string filter, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The list contains a only, while the targeted test finds b. For the homework settings, add one near-miss that exposes building a full key list merely to ask one ownership question. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: reading tracker. Stress-test the rule using own progress fields are distinguished from shared prototype methods. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Object.keys lists enumerable own string keys, whereas Object.hasOwn can test one non-enumerable or symbol key.” Apply this procedure: State the contract for Object.keys applies an enumerable string filter, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The list contains a only, while the targeted test finds b. For the reading tracker, add one near-miss that exposes building a full key list merely to ask one ownership question. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: science data. Explain the rule using a sparse measurement array separates holes from recorded undefined values. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Object.keys lists enumerable own string keys, whereas Object.hasOwn can test one non-enumerable or symbol key.” Apply this procedure: State the contract for Object.keys applies an enumerable string filter, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The list contains a only, while the targeted test finds b. For the science data, add one near-miss that exposes building a full key list merely to ask one ownership question. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: CCA form. Transfer the rule using untrusted field names cannot disable an ownership test by shadowing hasOwnProperty. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Object.keys lists enumerable own string keys, whereas Object.hasOwn can test one non-enumerable or symbol key.” Apply this procedure: State the contract for Object.keys applies an enumerable string filter, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The list contains a only, while the targeted test finds b. For the CCA form, add one near-miss that exposes building a full key list merely to ask one ownership question. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers building a full key list merely to ask one ownership question.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “State the contract for Object.keys applies an enumerable string filter, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final JavaScript Object.hasOwn() syntax. For this chapter, useful prompts are: “What did you expect from Object.keys applies an enumerable string filter?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing building a full key list merely to ask one ownership question be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny library catalogue with null-prototype lookup tables are checked safely. Include one ordinary case, one boundary and one deliberate failure caused by building a full key list merely to ask one ownership question. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: Object.keys lists enumerable own string keys, whereas Object.hasOwn can test one non-enumerable or symbol key. It shows a trace, not only a final value. The ordinary case should demonstrate “The list contains a only, while the targeted test finds b.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Object.keys applies an enumerable string filter, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For Object.keys applies an enumerable string filter, separate the documented JavaScript Object.hasOwn() mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
CHAPTER 18 OF 20 . Transfer with judgment
18. Property descriptors answer richer questions
Object.getOwnPropertyDescriptor is appropriate when the program needs value, writable, enumerable, configurable, getter or setter details. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is using a boolean ownership result to infer flags it never reports. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Property descriptors answer richer questions, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.
For the Property descriptors answer richer questions chapter on JavaScript Object.hasOwn(), use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on using a boolean ownership result to infer flags it never reports. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
const d=Object.getOwnPropertyDescriptor({x:1},'x');
console.log(Object.hasOwn({x:1},'x'),d.enumerable,d.writable);Explained result. Object.hasOwn answers presence only; the descriptor supplies the attribute details. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: science data. Stress-test the rule using a sparse measurement array separates holes from recorded undefined values. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Object.getOwnPropertyDescriptor is appropriate when the program needs value, writable, enumerable, configurable, getter or setter details.” Apply this procedure: State the contract for Property descriptors answer richer questions, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Object.hasOwn answers presence only; the descriptor supplies the attribute details. For the science data, add one near-miss that exposes using a boolean ownership result to infer flags it never reports. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: CCA form. Explain the rule using untrusted field names cannot disable an ownership test by shadowing hasOwnProperty. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Object.getOwnPropertyDescriptor is appropriate when the program needs value, writable, enumerable, configurable, getter or setter details.” Apply this procedure: State the contract for Property descriptors answer richer questions, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Object.hasOwn answers presence only; the descriptor supplies the attribute details. For the CCA form, add one near-miss that exposes using a boolean ownership result to infer flags it never reports. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: family budget. Transfer the rule using symbol metadata and non-enumerable state remain structurally visible. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Object.getOwnPropertyDescriptor is appropriate when the program needs value, writable, enumerable, configurable, getter or setter details.” Apply this procedure: State the contract for Property descriptors answer richer questions, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Object.hasOwn answers presence only; the descriptor supplies the attribute details. For the family budget, add one near-miss that exposes using a boolean ownership result to infer flags it never reports. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: library catalogue. Predict the rule using null-prototype lookup tables are checked safely. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Object.getOwnPropertyDescriptor is appropriate when the program needs value, writable, enumerable, configurable, getter or setter details.” Apply this procedure: State the contract for Property descriptors answer richer questions, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Object.hasOwn answers presence only; the descriptor supplies the attribute details. For the library catalogue, add one near-miss that exposes using a boolean ownership result to infer flags it never reports. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers using a boolean ownership result to infer flags it never reports.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “State the contract for Property descriptors answer richer questions, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final JavaScript Object.hasOwn() syntax. For this chapter, useful prompts are: “What did you expect from Property descriptors answer richer questions?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing using a boolean ownership result to infer flags it never reports be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny test laboratory with inheritance, getters, proxies, arrays, primitives and coercion expose boundaries. Include one ordinary case, one boundary and one deliberate failure caused by using a boolean ownership result to infer flags it never reports. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: Object.getOwnPropertyDescriptor is appropriate when the program needs value, writable, enumerable, configurable, getter or setter details. It shows a trace, not only a final value. The ordinary case should demonstrate “Object.hasOwn answers presence only; the descriptor supplies the attribute details.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Property descriptors answer richer questions, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For Property descriptors answer richer questions, separate the documented JavaScript Object.hasOwn() mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
CHAPTER 19 OF 20 . Transfer with judgment
19. A Proxy can observe the own-property operation
Because the check uses the receiver’s internal GetOwnProperty operation, a Proxy getOwnPropertyDescriptor trap may run and must obey invariants. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is calling the test free of observable behaviour for every exotic object. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for A Proxy can observe the own-property operation, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.
For the A Proxy can observe the own-property operation chapter on JavaScript Object.hasOwn(), use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on calling the test free of observable behaviour for every exotic object. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
const p=new Proxy({x:1},{getOwnPropertyDescriptor(t,k){console.log('check',k);return Reflect.getOwnPropertyDescriptor(t,k)}});
console.log(Object.hasOwn(p,'x'));Explained result. The trap logs the check and the result is true from the forwarded descriptor. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: family budget. Explain the rule using symbol metadata and non-enumerable state remain structurally visible. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Because the check uses the receiver’s internal GetOwnProperty operation, a Proxy getOwnPropertyDescriptor trap may run and must obey invariants.” Apply this procedure: State the contract for A Proxy can observe the own-property operation, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The trap logs the check and the result is true from the forwarded descriptor. For the family budget, add one near-miss that exposes calling the test free of observable behaviour for every exotic object. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: library catalogue. Transfer the rule using null-prototype lookup tables are checked safely. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Because the check uses the receiver’s internal GetOwnProperty operation, a Proxy getOwnPropertyDescriptor trap may run and must obey invariants.” Apply this procedure: State the contract for A Proxy can observe the own-property operation, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The trap logs the check and the result is true from the forwarded descriptor. For the library catalogue, add one near-miss that exposes calling the test free of observable behaviour for every exotic object. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: test laboratory. Predict the rule using inheritance, getters, proxies, arrays, primitives and coercion expose boundaries. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Because the check uses the receiver’s internal GetOwnProperty operation, a Proxy getOwnPropertyDescriptor trap may run and must obey invariants.” Apply this procedure: State the contract for A Proxy can observe the own-property operation, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The trap logs the check and the result is true from the forwarded descriptor. For the test laboratory, add one near-miss that exposes calling the test free of observable behaviour for every exotic object. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: design decision. Contrast the rule using Object.hasOwn is compared with in, Object.keys, value checks and property descriptors. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Because the check uses the receiver’s internal GetOwnProperty operation, a Proxy getOwnPropertyDescriptor trap may run and must obey invariants.” Apply this procedure: State the contract for A Proxy can observe the own-property operation, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The trap logs the check and the result is true from the forwarded descriptor. For the design decision, add one near-miss that exposes calling the test free of observable behaviour for every exotic object. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers calling the test free of observable behaviour for every exotic object.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “State the contract for A Proxy can observe the own-property operation, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final JavaScript Object.hasOwn() syntax. For this chapter, useful prompts are: “What did you expect from A Proxy can observe the own-property operation?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing calling the test free of observable behaviour for every exotic object be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny design decision with Object.hasOwn is compared with in, Object.keys, value checks and property descriptors. Include one ordinary case, one boundary and one deliberate failure caused by calling the test free of observable behaviour for every exotic object. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: Because the check uses the receiver’s internal GetOwnProperty operation, a Proxy getOwnPropertyDescriptor trap may run and must obey invariants. It shows a trace, not only a final value. The ordinary case should demonstrate “The trap logs the check and the result is true from the forwarded descriptor.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for A Proxy can observe the own-property operation, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For A Proxy can observe the own-property operation, separate the documented JavaScript Object.hasOwn() mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
CHAPTER 20 OF 20 . Transfer with judgment
20. Choose ownership only when ownership changes the decision
Use Object.hasOwn for explicit-input, sparse-structure and dictionary boundaries; use value, in, keys or descriptors when those are the actual questions. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.
The high-value mistake in this chapter is adding ownership checks everywhere and obscuring a simple value test. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Choose ownership only when ownership changes the decision, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.
For the Choose ownership only when ownership changes the decision chapter on JavaScript Object.hasOwn(), use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on adding ownership checks everywhere and obscuring a simple value test. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.
Core worked example
const limit=Object.hasOwn(options,'limit')?options.limit:defaultLimit;Explained result. An explicit limit including zero or undefined is distinguishable from an omitted limit, so ownership is the relevant contract. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.
Four purposeful transfer cases
Case 1: test laboratory. Transfer the rule using inheritance, getters, proxies, arrays, primitives and coercion expose boundaries. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Use Object.hasOwn for explicit-input, sparse-structure and dictionary boundaries; use value, in, keys or descriptors when those are the actual questions.” Apply this procedure: State the contract for Choose ownership only when ownership changes the decision, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: An explicit limit including zero or undefined is distinguishable from an omitted limit, so ownership is the relevant contract. For the test laboratory, add one near-miss that exposes adding ownership checks everywhere and obscuring a simple value test. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 2: design decision. Predict the rule using Object.hasOwn is compared with in, Object.keys, value checks and property descriptors. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Use Object.hasOwn for explicit-input, sparse-structure and dictionary boundaries; use value, in, keys or descriptors when those are the actual questions.” Apply this procedure: State the contract for Choose ownership only when ownership changes the decision, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: An explicit limit including zero or undefined is distinguishable from an omitted limit, so ownership is the relevant contract. For the design decision, add one near-miss that exposes adding ownership checks everywhere and obscuring a simple value test. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 3: homework settings. Contrast the rule using an explicit false or undefined choice is separated from an absent choice. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Use Object.hasOwn for explicit-input, sparse-structure and dictionary boundaries; use value, in, keys or descriptors when those are the actual questions.” Apply this procedure: State the contract for Choose ownership only when ownership changes the decision, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: An explicit limit including zero or undefined is distinguishable from an omitted limit, so ownership is the relevant contract. For the homework settings, add one near-miss that exposes adding ownership checks everywhere and obscuring a simple value test. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Case 4: reading tracker. Stress-test the rule using own progress fields are distinguished from shared prototype methods. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.
Reasoned route. Begin with “Use Object.hasOwn for explicit-input, sparse-structure and dictionary boundaries; use value, in, keys or descriptors when those are the actual questions.” Apply this procedure: State the contract for Choose ownership only when ownership changes the decision, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: An explicit limit including zero or undefined is distinguishable from an omitted limit, so ownership is the relevant contract. For the reading tracker, add one near-miss that exposes adding ownership checks everywhere and obscuring a simple value test. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.
Diagnostic route
- Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
- Boundary check: create the smallest input that triggers adding ownership checks everywhere and obscuring a simple value test.
- Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
- Repair check: use the reversible procedure “State the contract for Choose ownership only when ownership changes the decision, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
- Transfer check: repeat the rule in a second context and identify what remains invariant.
A parent does not need to know the final JavaScript Object.hasOwn() syntax. For this chapter, useful prompts are: “What did you expect from Choose ownership only when ownership changes the decision?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing adding ownership checks everywhere and obscuring a simple value test be made smaller?” The learner, not the parent, should supply the technical explanation.
Practice with an explained answer
Question. Build a tiny homework settings with an explicit false or undefined choice is separated from an absent choice. Include one ordinary case, one boundary and one deliberate failure caused by adding ownership checks everywhere and obscuring a simple value test. Predict each result before using a tool, then report the first point where observation differs from prediction.
Answer guide. A strong response starts with the rule: Use Object.hasOwn for explicit-input, sparse-structure and dictionary boundaries; use value, in, keys or descriptors when those are the actual questions. It shows a trace, not only a final value. The ordinary case should demonstrate “An explicit limit including zero or undefined is distinguishable from an omitted limit, so ownership is the relevant contract.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Choose ownership only when ownership changes the decision, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.
Decision and transfer
For Choose ownership only when ownership changes the decision, separate the documented JavaScript Object.hasOwn() mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.
Previous chapter . Contents . Next chapter
Parent guide: choose the next useful step
Start with evidence, not a label such as careless. Ask for one prediction and one trace. If the first transition is wrong, rebuild the model. If the model is sound but syntax fails, practise reference use. If routine cases are correct but boundaries fail, vary ties, defaults, unsupported inputs, ownership or missing paths. If explanations transfer, move to a small project.
Keep a weekly record with four lines: concept, prediction, observed difference and next test. Stop when fatigue replaces reasoning. A smaller case tomorrow is more useful than another hour of copying tonight.
Seek specialist help when cause and effect remain invisible after examples are reduced, when accessibility or data-loss implications are unclear, or when an important repository, database or application state may be at risk. Good support should make the learner’s reasoning more independent.
Capstone practice with explained routes
1. homework settings: model, boundary and recovery
Create a small homework settings using an explicit false or undefined choice is separated from an absent choice. Combine “Own properties differ from inherited properties” with one later chapter. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.
Explained route. Start with: Object.hasOwn returns true only when the receiver’s own property descriptor exists for the requested key. Apply: State the contract for Own properties differ from inherited properties, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Verify: local is true and shared is false because shared comes through the prototype. Then add a second chapter whose boundary could change the outcome. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement. The exact data may differ; the causal chain must be checkable.
2. reading tracker: model, boundary and recovery
Create a small reading tracker using own progress fields are distinguished from shared prototype methods. Combine “Non-enumerable properties still count as own” with one later chapter. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.
Explained route. Start with: Object.hasOwn does not require the property’s enumerable flag to be true. Apply: State the contract for Non-enumerable properties still count as own, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Verify: Object.keys is empty, but Object.hasOwn returns true for secret. Then add a second chapter whose boundary could change the outcome. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement. The exact data may differ; the causal chain must be checkable.
3. science data: model, boundary and recovery
Create a small science data using a sparse measurement array separates holes from recorded undefined values. Combine “Array indexes are own properties when present” with one later chapter. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.
Explained route. Start with: A populated array index is an own property of the array object. Apply: State the contract for Array indexes are own properties when present, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Verify: Index 0 is owned, while index 1 is absent. Then add a second chapter whose boundary could change the outcome. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement. The exact data may differ; the causal chain must be checkable.
4. CCA form: model, boundary and recovery
Create a small CCA form using untrusted field names cannot disable an ownership test by shadowing hasOwnProperty. Combine “Null-prototype objects are handled safely” with one later chapter. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.
Explained route. Start with: The static method does not depend on the receiver inheriting Object.prototype.hasOwnProperty. Apply: State the contract for Null-prototype objects are handled safely, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Verify: The result is true without requiring any inherited method. Then add a second chapter whose boundary could change the outcome. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement. The exact data may differ; the causal chain must be checkable.
5. family budget: model, boundary and recovery
Create a small family budget using symbol metadata and non-enumerable state remain structurally visible. Combine “Other primitives are boxed for the check” with one later chapter. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.
Explained route. Start with: ToObject wraps non-null primitives, allowing checks against their temporary object view. Apply: State the contract for Other primitives are boxed for the check, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Verify: The string owns indexed character 0 in its boxed view; the number does not own inherited toString. Then add a second chapter whose boundary could change the outcome. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement. The exact data may differ; the causal chain must be checkable.
6. library catalogue: model, boundary and recovery
Create a small library catalogue using null-prototype lookup tables are checked safely. Combine “The in operator includes the prototype chain” with one later chapter. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.
Explained route. Start with: key in object answers whether an own or inherited property is available; Object.hasOwn narrows the answer to direct ownership. Apply: State the contract for The in operator includes the prototype chain, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Verify: in returns true while Object.hasOwn returns false. Then add a second chapter whose boundary could change the outcome. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement. The exact data may differ; the causal chain must be checkable.
7. test laboratory: model, boundary and recovery
Create a small test laboratory using inheritance, getters, proxies, arrays, primitives and coercion expose boundaries. Combine “A Proxy can observe the own-property operation” with one later chapter. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.
Explained route. Start with: Because the check uses the receiver’s internal GetOwnProperty operation, a Proxy getOwnPropertyDescriptor trap may run and must obey invariants. Apply: State the contract for A Proxy can observe the own-property operation, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Verify: The trap logs the check and the result is true from the forwarded descriptor. Then add a second chapter whose boundary could change the outcome. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement. The exact data may differ; the causal chain must be checkable.
8. design decision: model, boundary and recovery
Create a small design decision using Object.hasOwn is compared with in, Object.keys, value checks and property descriptors. Combine “A present undefined value is still an own property” with one later chapter. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.
Explained route. Start with: Ownership depends on the descriptor, not on whether reading the value produces undefined. Apply: State the contract for A present undefined value is still an own property, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Verify: answer is owned and true; missing has no descriptor and is false. Then add a second chapter whose boundary could change the outcome. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement. The exact data may differ; the causal chain must be checkable.
Frequently asked questions
How long should a practice session be?
Use one complete prediction–observation–explanation cycle while attention remains good. Ten to twenty focused minutes can be enough.
Should every option or function be memorised?
No. Memorise the governing distinctions and practise retrieving the official reference. Understanding means predicting and explaining, not reciting a parameter list.
What if the result is correct but the explanation is weak?
Treat it as partial success. Ask for a trace and change one boundary. A reliable model survives controlled variation.
Is the shortest solution the best?
Not automatically. Prefer the solution whose semantics, failure modes and maintenance cost are easiest to justify for the actual project.
When should official documentation be used?
Use it whenever syntax, supported types, SQL dialect behaviour or Git version details matter. Primary documentation settles the current contract.
How can a parent help without technical expertise?
Ask what was predicted, where the first difference appeared, what evidence matters and which smaller example could isolate it.
How do we test transfer?
Change the context, vocabulary and one boundary. Require the learner to identify the invariant before using a tool.
What should be saved after practice?
Keep the corrected rule, one trace, one boundary case and the next question. Avoid storing pages of unexplained output.
Can these exercises replace backups?
No. Use disposable examples and proper backups. Learning should not endanger schoolwork, repositories or personal data.
What counts as mastery?
The learner can predict, verify, diagnose, recover and justify a choice across more than one context, while knowing when to consult the current reference.

