Symbol()
Creates a unique symbol every time, even with the same description.
Symbol and BigInt are primitive types for special jobs: unique property keys and integer values beyond the safe Number range.
const id = Symbol("id");
const huge = 9007199254740993n;
console.log(typeof id); // "symbol"
console.log(typeof huge); // "bigint"
Values & Types
Symbol creates unique primitive values. Even two symbols with the same description are different. Symbols are often used as unique object property keys or advanced protocol hooks.
BigInt represents large integers beyond the safe integer range of Number. It is useful for identifiers, counters and numeric domains where integer precision matters.
Both types have sharp edges. Symbols do not convert to strings implicitly like ordinary values. BigInt cannot be freely mixed with Number arithmetic and does not serialize to JSON by default.
Creates a unique symbol every time, even with the same description.
Uses the global symbol registry and can return the same shared symbol for a key.
Append n to an integer literal, such as 10n.
No fractions, no Math methods and no mixed arithmetic with Number.
Examples
const internalId = Symbol("internal-id");
const user = {
name: "User A",
[internalId]: "private-ish-key",
};
const chainHeight = 9007199254740993n;
console.log(typeof chainHeight); // "bigint"
const big = 10n; const normal = 5; console.log(big + normal); // TypeError: cannot mix BigInt and Number arithmetic
Rules that matter
JavaScript lets values move flexibly, but professional code keeps meaning clear. Convert at boundaries, validate input and choose values that represent the real idea.
Descriptions are labels for debugging, not identity.
The global registry creates shared symbols by key.
Do not use BigInt for decimal money or fractional measurements.
Convert deliberately when moving between Number and BigInt.
JSON.stringify throws on BigInt unless you provide a strategy.
BigInt operations are not guaranteed constant-time.
Production thinking
These types are not daily sugar. They exist because normal strings, numbers and object keys are not enough for every problem.
Symbol and BigInt rarely affect accessibility directly, but bugs in identifiers or counters can still break UI state and data display.
Production systems must define how BigInt crosses JSON, database and API boundaries. Symbols should not be used where ordinary public keys are expected.
Large numeric identifiers rendered incorrectly can break links, structured data or canonical references.
Live code lab
The preview runs inside an isolated iframe. The JavaScript is placed inside the HTML editor for now, so every example stays together and remains easy to understand.
Mini assignment
Practice assignment
Try it yourself
Self-check
Say the answer in plain language. If you can explain the value behavior, the code becomes much easier to debug.
Chapter checkpoint
Finish this chapter by turning the lessons into a small practical proof.
Create examples that compare strings, numbers, booleans, null, undefined and objects.
Can you predict the type of every value before running the code?