Published
Edited
Jan 5, 2022
9 stars
Insert cell
Insert cell
Insert cell
class Counter {
value = 0;
}
Insert cell
counter = new Counter()
Insert cell
counter.value
Insert cell
Insert cell
class Colors {
static red = "#ff0000";
static green = "#00ff00";
static blue = "#0000ff";
}
Insert cell
Colors.red
Insert cell
Insert cell
Insert cell
class Validator {
[Symbol.toStringTag] = "Validator";
}
Insert cell
(new Validator) + ""
Insert cell
Insert cell
class LazyValue {
#cache;
get value() {
return this.#cache ?? (this.#cache = Math.random());
}
}
Insert cell
lazy = new LazyValue()
Insert cell
lazy.value
Insert cell
Insert cell
lazy.value
Insert cell
Insert cell
class Branded {
#brand;
static isBranded(x) {
return x ? #brand in x : false;
}
}
Insert cell
b = new Branded()
Insert cell
Branded.isBranded(b)
Insert cell
Branded.isBranded({})
Insert cell
Branded.isBranded(null)
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