bigint
A primitive type for whole numbers of any size, written with an n suffix such as 9007199254740993n.
In more detail
Use bigint when integers go past Number.MAX_SAFE_INTEGER or when exact whole units such as cents must never drift. bigint and number cannot be mixed in arithmetic without converting. It needs an ES2020 or later target.
Example
const largeCount: bigint = 9007199254740993n;Related terms
- number (type) — The type of ordinary numeric values in JavaScript, both whole numbers and decimals, stored as 64-bit floating-point numbers.
- MAX_SAFE_INTEGER — The largest whole number, 9007199254740991, that a JavaScript number can store exactly.
- floating-point number — A number with a fractional part stored in binary, which can only approximate most decimal values.
Taught in
- Primitive Types: String, Number, Boolean, Bigint And Symbol — Production TypeScript
- never: The Bottom Type And Exhaustive Switch Checking — Production TypeScript