array2.slice().reverse()// Good: copy before mutate
{
constarray3=[0,1,2,3,4];
array3.reverse();// Good: mutation local to cell
returnarray3;
}
require("he")// Danger: loads the latest version of he, whatever that is!
require("he@1")// Good: pinned major version
require("he@1.2.0")// Also good: pinned exact version
require("he@1.2.0/he.js")// Also good: pinned exact version and path
{
// When this cell is re-run, mark the old object as dead.
constobject={alive:true};
invalidation.then(()=>object.alive=false);
returnobject;
}
{
for(leti=0;true;++i){
yieldi;
}
}
foo=htl.html`<div>foo</div>`
foo.textContent// Good: explicit reference to foo
htl.html`<div id=bar>bar</div>`
document.querySelector("#bar")// Bad: implicit reference to bar
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.