> For the complete documentation index, see [llms.txt](https://program.hackyourfuture.dk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://program.hackyourfuture.dk/course-content/frontend/advanced-javascript/week4/session-plan.md).

# Session Plan

## Session Materials

* [Demo](https://github.com/HackYourFuture-CPH/program/tree/main/courses/frontend/advanced-javascript/week4/session-materials/demo/README.md) – In-session live coding: plain-object motivation, `Comment` class, methods, flagged comments, then Errors / Web Components as “real world” context. **index.js** = worksheet; **index-solution.js** = reference. [README](https://github.com/HackYourFuture-CPH/program/tree/main/courses/frontend/advanced-javascript/week4/session-materials/demo/README.md).

## Session Outline

Start VERY simple. Just a class that has few fields, no methods. Explain the diff from object to class. Explain instance etc. When they get that move on to class methods. **Only teach extends if they really are on top of things** otherwise just get them comfortable with classes :) if you can repeat a bit of promise, maybe when working with class that would be great.

* Constructor
  * [Code inspiration](https://github.com/HackYourFuture-CPH/program/tree/main/courses/frontend/advanced-javascript/week4/session-materials/code-inspiration.md#constructor)
  * [Exercise](https://program.hackyourfuture.dk/course-content/frontend/advanced-javascript/week4/exercises.md#1-create-a-user-class)
* Instance
  * [Code inspiration](https://github.com/HackYourFuture-CPH/program/tree/main/courses/frontend/advanced-javascript/week4/session-materials/code-inspiration.md#instance)
  * [Exercise](https://program.hackyourfuture.dk/course-content/frontend/advanced-javascript/week4/exercises.md#2-create-an-instance-of-the-class)
* Methods (instance + static)
  * [Code inspiration](https://github.com/HackYourFuture-CPH/program/tree/main/courses/frontend/advanced-javascript/week4/session-materials/code-inspiration.md#methods)
  * [Code inspiration — static methods](https://github.com/HackYourFuture-CPH/program/tree/main/courses/frontend/advanced-javascript/week4/session-materials/code-inspiration.md#static-methods) (Promise as "you already use this")
  * [Exercise](https://program.hackyourfuture.dk/course-content/frontend/advanced-javascript/week4/exercises.md#3-create-a-class-method)
* `this`
  * Refers to the instance of the class. Do go into too much detail and edge cases. Avoid mentioning `bind`, `apply`, etc unless you find it super important, the trainees will just forget it anyway!
* [Exercise](https://program.hackyourfuture.dk/course-content/frontend/advanced-javascript/week4/exercises.md#4-creating-a-cv-class)
* Extend (Only if time!)
  * [Code inspiration](https://github.com/HackYourFuture-CPH/program/tree/main/courses/frontend/advanced-javascript/week4/session-materials/code-inspiration.md#extending-built-ins-error-and-web-components) (`Error`, `ValidationError`, Web Components sketch — matches demo Part 4)

## Exercises

See the separate [Exercises](https://program.hackyourfuture.dk/course-content/frontend/advanced-javascript/week4/exercises.md) document.

## Code inspiration

See the separate [Code inspiration](https://github.com/HackYourFuture-CPH/program/tree/main/courses/frontend/advanced-javascript/week4/session-materials/code-inspiration.md) document.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://program.hackyourfuture.dk/course-content/frontend/advanced-javascript/week4/session-plan.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
