Published
Edited
Dec 4, 2019
Insert cell
Insert cell
[1, 2, 3].map((value, index, values) => ({ value, index, values }))
Insert cell
Insert cell
[1, 2, 3].map(value => value * 2)
Insert cell
Insert cell
villes = [
{ nom: 'Lausanne', population: 138905 },
{ nom: 'Yverdon', population: 30143 },
{ nom: 'Montreux', population: 26574 },
{ nom: 'Renens', population: 21036 },
{ nom: 'Nyon', population: 20533 },
{ nom: 'Vevey', population: 19827 },
]
Insert cell
Insert cell
villes.map(({ nom }) => nom.toUpperCase())
Insert cell
Insert cell
villes.map(ville => ({ ...ville, population: ville.population * 2 }))
Insert cell
Insert cell
lausanne = ({ ...villes[0], capitale: true })
Insert cell
Insert cell
capitalizeName = ville => ({ ...ville, nom: ville.nom.toUpperCase() })
Insert cell
doublePopulation = ville => ({ ...ville, population: ville.population * 2 })
Insert cell
addCapital = ville => ({ ...ville, capitale: ville.nom === 'LAUSANNE' })
Insert cell
villes.map(capitalizeName)
.map(doublePopulation)
.map(addCapital)
Insert cell
Insert cell
[1, 2, 3].reduce((sum, value) => sum + value, 0)
Insert cell
Insert cell
Insert cell
Insert cell
dates = Object.keys(forex.rates)
Insert cell
Insert cell
dates.reduce(
(list, date) => ([...list, { ...forex.rates[date], date }]),
[]
)
Insert cell
Insert cell
{
const list = [1, 2, 3]
return [...list, 4, 5, 6]
}
Insert cell
Insert cell
{
const list1 = [1, 2, 3]
const list2 = [4, 5, 6]
const list3 = [7, 8, 9]
return [...list1, ...list2, ...list3]
}
Insert cell
Insert cell
villes.filter(ville => ville.population > 30000)
Insert cell
Insert cell
villes.find(ville => ville.population > 30000)
Insert cell
Insert cell
villes.find(ville => ville.population > 1000000)
Insert cell
Insert cell
villes.filter(ville => ville.population > 1000000)
Insert cell
Insert cell
R.path(['rates', '2018-01-02', 'CHF'], forex)
Insert cell
Insert cell
forex.rates['2018-01-02'].CHF
Insert cell
Insert cell
R.path(['rates', '2018-01-01', 'CHF'], forex)
Insert cell
Insert cell
forex.rates['2018-01-01'].CHF
Insert cell
Insert cell
R.omit(['a', 'c'], { a: 1, b: 2, c: 3 })
Insert cell
Insert cell
omit = (keysToOmit, object) => Object.keys(object)
.reduce(
(result, key) => keysToOmit.includes(key)
? result
: { ...result, [key]: object[key]},
{}
)
Insert cell
omit(['a', 'c'], {a: 1, b: 2, c: 3})
Insert cell
Insert cell
R.pick(['a', 'c'], { a: 1, b: 2, c: 3 })
Insert cell
Insert cell
R.assocPath(['a', 'b', 'c'], 5, { a: { b: { c: 1 } } })
Insert cell
Insert cell
R.assocPath(['a', 'b', 'c'], 5, { a: 1 })
Insert cell
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
Insert cell
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

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