Public
Edited
Mar 2, 2023
1 fork
35 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Look at me, I’m <mark>marked text</mark>!
Insert cell
<style>
mark {
background-color: cyan;
}
</style>
Insert cell
Insert cell
Insert cell
Insert cell
array = [0, 1, 2, 3, 4]
Insert cell
array // Bad: nondeterministic order
Insert cell
array.reverse() // Bad: mutates array
Insert cell
Insert cell
Insert cell
Insert cell
array2 = [0, 1, 2, 3, 4]
Insert cell
array2.slice().reverse() // Good: copy before mutate
Insert cell
{
const array3 = [0, 1, 2, 3, 4];
array3.reverse(); // Good: mutation local to cell
return array3;
}
Insert cell
Insert cell
Insert cell
require("he") // Danger: loads the latest version of he, whatever that is!
Insert cell
require("he@1") // Good: pinned major version
Insert cell
require("he@1.2.0") // Also good: pinned exact version
Insert cell
require("he@1.2.0/he.js") // Also good: pinned exact version and path
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
// When this cell is re-run, mark the old object as dead.
const object = {alive: true};
invalidation.then(() => object.alive = false);
return object;
}
Insert cell
{
for (let i = 0; true; ++i) {
yield i;
}
}
Insert cell
Insert cell
Insert cell
foo = htl.html`<div>foo</div>`
Insert cell
foo.textContent // Good: explicit reference to foo
Insert cell
Insert cell
htl.html`<div id=bar>bar</div>`
Insert cell
document.querySelector("#bar") // Bad: implicit reference to bar
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more