
JavaScript Data Types and Type System
Understanding Primitive and Object Types
Catalog
Click on this table of contents to jump to the corresponding section
JavaScript has 8 Datatypes:
- String
- Number
- Bigint
- Boolean
- Undefined
- Null
- Symbol
- Object
The Object Datatype
The object data type can contain:
- An object
- An array
- A date
Note: A JavaScript variable can hold any type of data.
The Concept of Data Types
In programming, data types is an important concept. To be able to operate on variables, it is important to know something about the type. Without data types, a computer cannot safely solve this:
Does it make any sense to add "Volvo" to sixteen? Will it produce an error or will it produce a result? JavaScript will treat the example above as:
Note: When adding a number and a string. JavaScript will treat the number as string
Note: When adding a number and a string. JavaScript will treat the number as string
JavaScript evaluates expressions from left to right. Different sequences can produce different results:
Result
In the first example, JavaScript treats 16 and 4 as numbers, until it reaches "Volvo". In the second example, since the first operand is a string, all operands are treated as strings.
JavaScript Types are Dynamic
JavaScript has dynamic types. This means that the same variable can be used to hold different data types:
JavaScript Strings
A string (or a text string) is a series of characters like "John Doe". Strings are written with quotes. You can use single or double quotes:
You can use quotes inside a string, as long as they don't match the quotes surrounding the string:
JavaScript Numbers
All JavaScript numbers are stored as decimal numbers (floating point). Numbers can be written with, or without decimals:
Exponential Notation
Extra large or extra small numbers can be written with scientific (exponential) notation:
JavaScript BigInt
All JavaScript numbers are stored in a a 64-bit floating-point format.
JavaScript BigInt is a new datatype (ES2020) that can be used to store integer values that are too big to be represented by a normal JavaScript Number.
JavaScript Booleans
Booleans can only have two values: true or false.
Booleans are often used in conditional testing.
JavaScript Arrays
JavaScript arrays are written with square brackets.
Array items are separated by commas.
The following code declares (creates) an array called cars, containing three items (car names):
Array indexes are zero-based, which means the first item is [0], second is [1], and so on.
JavaScript Objects
JavaScript objects are written with curly braces {}. Object properties are written as “name:value” pairs, separated by commas.
The object (person) in the example above has 4 properties: firstName, lastName, age, and eyeColor.
The typeof Operator
You can use the JavaScript typeof operator to find the type of a JavaScript variable. The typeof operator returns the type of a variable or an expression:
Undefined
In JavaScript. a variable without a value, has the value undefined. The type is also undefined.
Any variable can be emptied, by setting the value to undefined. The type will also be undefined.
Empty Values
An empty value has nothing to do with undefined. An empty string has both a legal value and a type.
Lily and 4 people like this
Prev Post
Space The Final Frontier
Next Post
Telescopes 101
0 Comments
Leave a Reply
Recent Post

SMOTE for Imbalanced Classification with Python
12:28:00 16/05/2026

CLAHE Histogram Equalization with OpenCV: A Python Guide
12:06:00 16/05/2026

Histogram Equalization in Digital Image Processing
10:56:00 16/05/2026

Gaussian Noise Explained: What It Is and How It Works
10:36:00 16/05/2026

Python Image Blurring with OpenCV: Gaussian, Median & Bilateral Filter Guide
09:59:00 16/05/2026
Related Topics
Feeds
Don't miss what's next 👋
Enjoyed this content? Leave your email to get notified when we publish new insights, tutorials, and updates — no spam, ever.

