Published
Edited
May 27, 2020
34 stars
Insert cell
Insert cell
Insert cell
(123.456789).toLocaleString()
Insert cell
(0.1 * 6).toLocaleString()
Insert cell
(0.1 * 6).toLocaleString(undefined, {minimumFractionDigits: 3})
Insert cell
(0.1 * 6).toLocaleString(undefined, {maximumFractionDigits: 16})
Insert cell
Insert cell
(123456).toLocaleString(undefined, {maximumSignificantDigits: 3})
Insert cell
Insert cell
(123456).toExponential(2)
Insert cell
Insert cell
(123).toLocaleString(undefined, {minimumIntegerDigits: 8})
Insert cell
Insert cell
(123).toLocaleString().padStart(10, " ")
Insert cell
(123).toLocaleString().padEnd(10, " ")
Insert cell
Insert cell
(1234).toLocaleString()
Insert cell
(1234).toLocaleString(undefined, {useGrouping: false})
Insert cell
Insert cell
(1234.56).toLocaleString("de-DE")
Insert cell
(1234.56).toLocaleString("ar-EG")
Insert cell
(123456).toLocaleString("en-IN")
Insert cell
Insert cell
(0.45).toLocaleString(undefined, {style: "percent"})
Insert cell
(0.45).toLocaleString(undefined, {
style: "percent",
maximumSignificantDigits: 1
})
Insert cell
Insert cell
(1234).toLocaleString("en-US", {
style: "currency",
currency: "USD"
})
Insert cell
(1234.56).toLocaleString("en-US", {
style: "currency",
currency: "USD",
currencyDisplay: "code", // ISO code instead of dollar sign.
minimumFractionDigits: 0, // Hide cents (if exact dollar).
maximumFractionDigits: 0 // Round to the nearest dollar.
})
Insert cell
(1234).toLocaleString("en-US", {
style: "currency",
currency: "USD",
currencyDisplay: "name"
})
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