Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 1.2 — Primitive Types
JavaScript · Example 4 of 4 ES2020+

Symbols are unique, bigints are exact

Symbols arrived in ES2015 and description in ES2019; BigInt in ES2020. Topic 1.3 explains why such big numbers need BigInt.

JavaScript has seven primitive types (string, number, boolean, null, undefined, bigint and symbol) plus objects; typeof tells you a value's type, with a few famous quirks.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 5 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Log the type of each of these values: "", 0, false, [], {}, null.

02

Write two lines that prove strings are copied by value: copy a string into a second variable, change the second one, and log both.

Explain it without notes

01

Name JavaScript's primitive types. What makes a value primitive?

02

Why is typeof null equal to "object", and how do you correctly check for null and for arrays?

03

What is the difference between null and undefined?

04

How can "abc".length work if strings are not objects?

Symbols are unique, bigints are exact ES2020+

Console

(nothing was printed)

Expected console output

false
Symbol(id)
id
9007199254740994n
bigint