Published
Edited
Apr 28, 2020
1 star
Insert cell
Insert cell
polyfill = Map => {
Map.prototype.filter = function(d) {
return new Map(Array.from(this).filter(([key, value]) => d(value, key)));
};
Map.prototype.map = function(d) {
return new Map(
Array.from(this).map(([key, value]) => [key, d(value, key)])
);
};
return Map;
}
Insert cell
m = new Map([[1, "A"], [2, "B"]])
Insert cell
m.filter((value, key) => key == 1)
Insert cell
m.map((value, key) => value.toLowerCase())
Insert cell
m.map(value => value.toLowerCase())
Insert cell
ok = polyfill(Map)
Insert cell
(ok, m.filter((value, key) => key == 1))
Insert cell
(ok, m.map((value, key) => value.toLowerCase()))
Insert cell
(ok, m.map(value => value.toLowerCase()))
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