Published
Edited
May 11, 2020
Insert cell
md`# How to access static getter on class in a constructor`
Insert cell
new Bar({ hello: 'world'})
Insert cell
class Bar extends Foo {
static get value () {
return 'baz';
}
}
Insert cell
new Foo()
Insert cell
class Foo {
static get value () {
return 'bar';
}
constructor (obj = {}) {
this.value = this.constructor.value;
this.data = { ...obj, value: this.constructor.value };
}
toString() {
return `value: ${this.value}`;
}
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more