Key Takeaways
- JavaScript values have types, but variables are not permanently locked to one type.
- JavaScript has seven primitive types: string, number, bigint, boolean, undefined, symbol, and null.
typeofis useful, but it has one famous historical surprise:typeof nullreturns"object".
In OSJavaScript.001, we established that JavaScript is the language, a JavaScript engine executes it, and a host environment such as a browser or Node.js supplies extra APIs. This lesson moves one level deeper: what kinds of values can JavaScript actually represent?
Unlike the Java lesson immediately before this one, where a variable declaration such as int age = 25; fixes the variable to an integer type, JavaScript is dynamically typed. A binding can hold a number now and a string later. That contrast is useful if you just read OSJava.002: Primitive Types and Variables.
Values Have Types
A JavaScript program manipulates values. Every value belongs to a type. The official MDN data-types guide divides JavaScript values into primitives and objects. The primitive values are the simplest immutable values defined by the language.
const name = "Amina";
const count = 42;
const ready = true;
Here, "Amina" is a string value, 42 is a number value, and true is a boolean value. const prevents the binding from being reassigned; it does not create a special new data type.

The Seven Primitive Types
| Primitive | Example | Typical meaning | typeof |
|---|---|---|---|
| string | "hello" | Text | "string" |
| number | 42, 3.14 | Ordinary numeric values | "number" |
| bigint | 9007199254740993n | Arbitrarily large integers | "bigint" |
| boolean | true | Logical true/false state | "boolean" |
| undefined | undefined | Value not assigned / absent by default | "undefined" |
| symbol | Symbol("id") | Unique identifier-like primitive | "symbol" |
| null | null | Intentional absence of a value/object reference | "object" — historical quirk |
Everything that is not a primitive value is an object. Arrays, ordinary objects, dates, maps, regular expressions, and functions all live on the object side of JavaScript’s type system, although typeof reports callable functions as "function".
String: Text Data
Strings represent text. JavaScript supports single quotes, double quotes, and template literals with backticks.
const first = "Bitcoin";
const second = 'JavaScript';
const message = `Learning ${second}`;
Strings are immutable: operations that appear to modify a string actually produce a new string value. If your editor visually separates strings, keywords, numbers, and identifiers, that is the same syntax highlighting covered in our earlier coding explainer.
Number: Integers and Decimals Share One Main Type
JavaScript’s ordinary number type uses IEEE 754 double-precision floating-point representation. That means ordinary integers and decimals normally share the same type.
typeof 42; // "number"
typeof 3.14; // "number"
typeof NaN; // "number"
typeof Infinity;// "number"
NaN means “Not-a-Number,” but it is still a value in the Number type. That odd-looking detail makes more sense once you distinguish a value’s name from its underlying type.
BigInt: Integers Beyond Number’s Safe Integer Range
For integers larger than JavaScript can represent exactly with ordinary Number values, JavaScript provides BigInt. A BigInt literal ends with n.
const huge = 9007199254740993n;
console.log(typeof huge); // "bigint"
BigInt is not simply “a more precise Number.” It is a distinct primitive type for integers. You generally cannot mix BigInt and Number directly in arithmetic without an explicit conversion.
Boolean: true or false
A boolean has exactly two values: true and false. Booleans become especially important when we reach comparisons, conditionals, loops, and application state.
const connected = true;
const maintenanceMode = false;
undefined and null Are Not the Same
undefined often means JavaScript has no value there yet. For example, a let declaration without an initializer receives undefined.
let result;
console.log(result); // undefined
console.log(typeof result); // "undefined"
null, by contrast, is normally written deliberately by the programmer to represent an intentional empty or missing value. The exact semantics are application-specific, but treating null and undefined as identical concepts is a common beginner mistake.
Symbol: Unique Primitive Values
A Symbol is a unique primitive value commonly used for unique property keys. Two symbols created with the same description are still different values.
const firstId = Symbol("id");
const secondId = Symbol("id");
console.log(firstId === secondId); // false
You will not need Symbol constantly in beginner programs, but it belongs in the complete primitive-type model and should not be omitted just because it is less common than strings or numbers.
typeof Lets You Inspect a Value’s Type
The unary typeof operator returns a string describing the operand’s type category. MDN’s typeof reference documents the exact return strings.
console.log(typeof "hello"); // "string"
console.log(typeof 42); // "number"
console.log(typeof 42n); // "bigint"
console.log(typeof true); // "boolean"
console.log(typeof undefined); // "undefined"
console.log(typeof Symbol()); // "symbol"
The Famous typeof null Surprise
console.log(typeof null); // "object"
This does not mean null is an object. null is a primitive value. The "object" result is a long-standing historical behavior preserved for web compatibility. To test specifically for null, use a strict comparison such as value === null.
Primitive Values Are Immutable
Primitive values themselves cannot be mutated. A variable can be reassigned to a different primitive, but that does not modify the old primitive value.
let word = "cat";
word = "dog";
The string "cat" was not changed into "dog". The binding named word was reassigned to a different string value. This distinction becomes important when you later compare primitives with objects and arrays.
JavaScript Is Dynamically Typed
A JavaScript binding does not permanently declare one value type. The value can change type at runtime.
let value = 42;
value = "forty-two";
value = true;
This flexibility is one reason TypeScript exists: it adds static type checking around JavaScript development. BitcoinVersus.Tech has followed that tooling layer in stories such as ts-rust Ports TypeScript 7’s Compiler to Rust and the earlier GitHub Copilot TypeScript Runtime rewrite.
A Small Type-Inspection Program
const values = [
"hello",
42,
42n,
true,
undefined,
null,
Symbol("id")
];
for (const value of values) {
console.log(value, typeof value);
}
Run this in the browser console introduced in OSJavaScript.001. Pay special attention to the line for null. The experiment is more useful than memorizing a list because it lets you observe the language directly.
Common Beginner Mistakes
- Saying JavaScript has only six primitive types: modern JavaScript has seven; BigInt and Symbol count.
- Calling null an object because typeof says object: null is a primitive.
- Treating null and undefined as identical: they often represent different kinds of absence.
- Assuming integers have a separate int type: ordinary integers and decimals normally use Number.
- Mixing BigInt and Number arithmetic casually: they are distinct numeric types.
- Thinking const makes an object immutable: const prevents rebinding; object mutation is a separate concept.
Practice
- Open a browser developer console.
- Create one value for each of JavaScript’s seven primitive types.
- Run
typeofon each value. - Confirm that
typeof nullreturns"object". - Compare two separately created symbols with the same description.
- Create a BigInt literal and inspect it with
typeof. - Declare a
letbinding, assign it a number, then a string, and observe that JavaScript permits the type to change.
Knowledge Check + Answers
- How many primitive types does JavaScript have? Seven.
- Name them. String, Number, BigInt, Boolean, Undefined, Symbol, and Null.
- Is null an object? No. It is a primitive value.
- What does typeof null return?
"object", for historical compatibility reasons. - What does typeof 42n return?
"bigint". - What is the difference between undefined and null at a beginner level? Undefined commonly represents a value that has not been supplied or assigned; null is commonly written deliberately to represent an intentional empty value.
- Can a let binding hold a number and later a string? Yes.
- Are primitive values mutable? No.
- What is Symbol useful for? Creating unique primitive values, often for unique object property keys.
Elementary Review
JavaScript values have types even though variables are dynamically typed. Learn the seven primitives first: string, number, bigint, boolean, undefined, symbol, and null. Use typeof to inspect values, but remember the special null result.
Next JavaScript Lesson
OSJavaScript.003: Variables and Constants — let, const, var, Reassignment, Scope, and the Temporal Dead Zone will build on these values by focusing on how JavaScript creates and manages bindings.
Editor’s Note
The featured artwork is a unique 1200×630 realistic color-pencil illustration created specifically for this lesson and is not reused in the body. The separate body image is real JavaScript source code by Lionel Rowe from Wikimedia Commons, released under CC0 1.0.
BitcoinVersus.Tech content is provided for informational and educational purposes.

Leave a Reply