Understand shared behavior and object construction.
- class
- constructor
- prototype
- this
Classes provide syntax for constructors and prototype methods. Methods are shared through the prototype, while instance fields belong to each object. this depends on how a normal function is called, so methods passed as callbacks may lose their expected receiver. Prefer composition when inheritance adds unnecessary coupling.
Copying a method into a variable can change this and cause a runtime error.
Create a Timer class with start and stop; explain which data is per instance and which method is shared.
Open example.html in a browser and edit example.js. Save, refresh, and use the Console and debugger to inspect values.
- Explain the core idea in your own words without reading the code.
- Change one input and predict the output before running it.
- Test one boundary or failure case, then record what you changed.