CKTIS / JavaScript
JavaScript type system
JavaScript is dynamically typed: types belong to values, and a variable declared with let can hold values of different types over time. Learn the eight language types, conversions, and the limitations of the typeof operator.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
let value = 7;
value = "7";
typeof valueA type system defines kinds of values and the rules for operating on them. JavaScript is dynamically typed: values have types, but a variable declared with let is not permanently tied to the type of its first assigned value. Assigning a new value does not change the type of the previous value.
ECMAScript defines eight language types: Undefined, Null, Boolean, String, Symbol, Number, BigInt, and Object. The first seven are primitive types. Arrays and functions are objects, not additional language types. Number and BigInt are distinct numeric types.
Dynamic typing does not mean every operation is allowed. Operators have specific implicit conversion rules: "7" + 1 produces the string "71". Explicit Number("7") obtains a number before addition. The === operator does not convert operands to a common type, so "7" === 7 produces false. Some invalid type combinations throw TypeError.
typeof returns a string category for a value, not a complete description of its type. In particular, typeof null produces "object", although null is a primitive value of type Null; functions produce "function", although they belong to Object. To identify null, use value === null. The example demonstrates a change in the assigned value's type, conversion, and this typeof pitfall.
Examples
let value = 7;
console.log(typeof value);
value = "7";
console.log(typeof value);
console.log(value + 1);
console.log(Number(value) + 1);
console.log(value === 7);
console.log(typeof null);Result
number string 71 8 false object
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.