Published
Edited
Aug 13, 2021
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
removeItem = (itm, arr) => {
// pass in an array and an item. Run filter on the array to return a new array with that item removed.
let res = arr.filter((x)=>{
return x != itm;
})
return res
}
Insert cell
viewof button = Inputs.button("Remove 'remove me'", {reduce: ()=>{
// reassign a value to myArray to trigger Observable's reactive functionality.
mutable myArray = removeItem("remove me", myArray);
}})
Insert cell
Insert cell
Insert cell
html`${
myArray.map((itm,idx,arr) => {
return `<div>Element (${idx}): ${itm}</div>`
},"").join("")
}`;
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