Getters, Setters and Static Members
In short: get name() { ... } and set name(value) { ... } define a
property that looks like plain data (obj.name, no parentheses) but
actually runs code whenever it's read or written — useful for
computed values or validation. static fields and methods work
completely differently: they belong to the class itself, shared by
every instance, and they are never copied onto instances the way regular
methods and constructor-set properties are. Reach for a static member for
anything that's true of the whole class — a running count, a factory
method — not any one particular object.

Read and write a computed property
A getter and setter pair lets song.minutes behave like ordinary data,
while secretly converting to and from a different stored value:
s.minutes reads 3.5 — no parentheses, just like a plain property, even
though a whole calculation runs behind it. s.minutes = 4 looks like an
ordinary assignment too, but it actually calls the set minutes method,
which converts 4 minutes back into 240 stored seconds.
Track something true of the whole class, not one instance
A static field belongs to the class — every constructor call can update
the same shared value, and a static method is only callable on the
class itself:
Song.count is one shared number, incremented by every new Song(...)
call — not a separate counter per instance. Song.describeAll() is only
reachable on the class itself.
The trap: reaching for a static method through an instance
A static member is never copied onto instances — reaching for it
through one fails, even though the class it belongs to made that very
instance:
This throws TypeError: s.describeAll is not a function. describeAll
genuinely doesn't exist on s — only on Song itself. Static members and
instance members live in two entirely separate places.
Quick practice
What does get minutes() { return this._seconds / 60; } let you write?
What does s.minutes = 4; actually do, given a set minutes(value) method?
Where does a static field or method live?
What happens when you call a static method through an instance, like s.describeAll()?
Given static count = 0; and every constructor doing Song.count++, does each instance get its own separate count?
🎯 Your turn
Given
class Song { static count = 0; constructor(title) { this.title = title; Song.count++; } static describeAll() { return \${Song.count} songs`; } }, explain why const s = new Song("a"); s.describeAll();throws, whileSong.describeAll()works, and whySong.count` correctly reflects every
instance ever created.
Write your explanation and submit it — there's no code to run here, just your reasoning.
