Public
Edited
Feb 15, 2024
Insert cell
Insert cell
## Basic Data Type
Insert cell
// Variable x = Number 23
x = 23
Insert cell
// String are written in Single Quotes or Double Quotes
y = "Inxd"
Insert cell
z = "I'am learning by typing along with Amit"
Insert cell
// Multiline Strings - Backtick
long_line = `This is learning
something that is new
While I am struggling
to get started`
Insert cell
sample = `area,sales,profit
north,5,2
east,25,8
west,15,6
south,20,5
central,10,3`
Insert cell
// Boolean is true or false
bool_var = false
Insert cell
// Date
today = new Date(1707903643429).toString()
Insert cell
Date.now()
Insert cell
Insert cell
function f(x) {
var y = x + 1;
return y;
}
Insert cell
f(3)
Insert cell
function sum(a, b) {
return a + b;
}
Insert cell
sum(2, 4)
Insert cell
sum("hello", "world")
Insert cell
### Short Form Function

- Arrow Function
- Anonymous Function
Insert cell
sumshort = (a, b) => a + b
Insert cell
// Anonymous
(a, b) => a + b
Insert cell
Insert cell
## Array []
Insert cell
prime = [2, 3, 5, 7, 11, 13]
Insert cell
prime[0]
Insert cell
prime[1] + prime[4]
Insert cell
Insert cell
shortNames = ({
india: "IN",
china: "CN",
russia: "RU"
})
Insert cell
shortNames.india
Insert cell
shortNames["india"]
Insert cell
Insert cell
// csv data
sample1 = `area,sales,profit
north,5,2
east,25,8
west,15,6
south,20,5
central,10,3`
Insert cell
dataRow = d3.csvParse(sample1, d3.autoType)
Insert cell
dataRow[0]
Insert cell
Insert cell
dataCol = ({
area: ["north", "east", "west", "south", "central"],
sales: [5, 25, 15, 20, 10],
profit: [2, 8, 6, 5, 3]
})
Insert cell
dataCol.area
Insert cell
## Visualisation

Grouped Chart
Insert cell
Inputs.table(dataRow, { width: 400 })
Insert cell
dataTall = aq.from(dataRow).fold(["sales", "profit"])
Insert cell
Inputs.table(dataTall, { width: 400 })
Insert cell
Plot.plot({
x: { axis: null },
marks: [
Plot.barY(dataTall, { x: "key", y: "value", fx: "area", fill: "key" })
]
})
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