Tsallaka zuwa abun ciki
Justice Tech School

Getters, Setters and Static in Classes

get and set make computed or validated properties. static members belong to the class. Use them for utilities and factories.

Example
class Temp {
  static fromF(f) { return new Temp((f - 32) * 5 / 9); }
  constructor(c) { this.c = c; }
  get f() { return this.c * 9 / 5 + 32; }
}
console.log(Temp.fromF(212).c, new Temp(0).f);

Exercise

Class level method.

 create() {}

Quiz Test

Where do static methods live?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.