Objective: Plug & chug, ~3 minutes: the facts an object carries, and the moment it's set up.
⏱ ≈14 min full lesson · Converted from the O-02 module deck · English edition — Español · العربية · বাংলা in translation
Plug & chug, ~3 minutes: the facts an object carries, and the moment it's set up.
Facts and abilities: A class holds two kinds of things: PROPERTIES — facts it remembers (a page's expected title) — and METHODS — things it can do (go, verify). This module is about the facts, and where they come from.
A real property + a real constructor: expectedTitle is a fact HomePage carries. The CONSTRUCTOR is a special method that runs the moment an object is built with new — here it receives the browser page and stores it: this.page means “the page stored on THIS object.” Code: readonly expectedTitle = "Aoma AI Agency — Get Found. Miss Fewer Leads."; | constructor(page: Page) { | this.page = page; | }
Plug & chug: the waiter clocks in: A waiter remembers the menu (properties) and takes orders (methods). The constructor is the clock-in moment: the waiter is handed their section — in code, the page. When does the constructor run? At ______ time.
Properties are an object's facts; the constructor hands it what it needs at birth. Next: methods — its verbs.