Published
Edited
May 24, 2020
7 stars
Insert cell
md`# Persist data of a cell in local storage`
Insert cell
mutable data = {
var initial = JSON.parse(localStorage.getItem("data") || "[]");
return initial;
}
Insert cell
viewof click_this = {
var button = html`<button>Add random value to data`;
button.addEventListener('click', () => {
mutable data = mutable data.concat([Math.random()]);
localStorage.setItem("data", JSON.stringify(mutable data));
});
return button;
}
Insert cell
data.length
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