Data Types (JavaScript):

Primary Data Types
The primary (primitive) data types are:
String, Number, Boolean

Composite Data Types
The composite (reference) data types are:
Object, Array

Special Data Types
The special data types are:
Null, Undefined

Click here for details:

  var test1 = 1;
  var test2 = "Something";
  var test3 = true;
  var test4 = {};
  var test5 = new Array();
  var test6 = new Date();
  var test7;
  var test8 = null;

  alert(typeof (test1)); //number
  alert(typeof (test2)); //string
  alert(typeof (test3)); //boolean
  alert(typeof (test4)); //object
  alert(typeof (test5)); //object
  alert(typeof (test6)); //object
  alert(typeof (test7)); //undefined
  alert(typeof (test8)); //object
Answer from Sudipta Kumar Maiti on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › primitive-and-non-primitive-data-types-in-javascript
Primitive and Non-primitive data-types in JavaScript - GeeksforGeeks
Below is a list of Non-primitive data types. An object in Javascript is an entity having properties and methods. Everything is an object in javascript. ... // Create an empty generic object let obj = new Object(); // Create a user defined object let mycar = new Car(); ... // An empty object let square = {}; // Here a and b are keys and // 20 and 30 are values let circle = {a: 20, b: 30}; Example: Below is an example.
Published   July 23, 2025
🌐
DEV Community
dev.to › imashwani › javascript-non-primitive-data-types-2mjp
JavaScript Non-Primitive Data Types - DEV Community
April 2, 2024 - The object (person) in the example above has 4 properties: firstName, lastName, age, and eyeColor. ... As we know, arrays fall in the object category of JavaScript data types i.e they are stored by references and NOT by their actual values.
People also ask

What are data types in JavaScript?
Data types in JavaScript define the kind of values you can store and use in a program. They help you manage and perform operations on different kinds of data efficiently.
🌐
wscubetech.com
wscubetech.com › resources › javascript › data-types
JavaScript Data Types: Primitive & Non-Primitive With Examples
What are the different data types in JavaScript?
There are two major types of data types in JS:Primitive: String, Number, Null, Boolean, Undefined, BigInt, and SymbolNon-primitive: Object, Array, Function
🌐
wscubetech.com
wscubetech.com › resources › javascript › data-types
JavaScript Data Types: Primitive & Non-Primitive With Examples
How many data types are there in JavaScript?
There are two main data types in JavaScript: Primitive and Non-Primitive. Primitive data types include seven types: String, Number, Boolean, Null, Undefined, BigInt, and Symbol, while non-primitive types include Object, Array, and Function.
🌐
wscubetech.com
wscubetech.com › resources › javascript › data-types
JavaScript Data Types: Primitive & Non-Primitive With Examples
🌐
DEV Community
dev.to › mrizwanashiq › primitive-and-non-primitive-56n8
Primitive and Non-primitive - DEV Community
June 8, 2023 - In the above example, we have created an object named person and assigned the value { name: 'Rizwan', age: 25 } to it. Then, we have tried to change the value of the name property to 'rizwan' using the dot notation. And, we got the updated value in the console. This is because the object is a non-primitive data type, and it is mutable.
🌐
Scaler
scaler.com › topics › non-primitive-data-types-in-javascript
Non-primitive data types in Javascript | Scaler Topics
November 15, 2022 - Variables of non-primitive data types are stored in the heap memory of the system, while primitive data types variables are stored in the stack space of the system. ... Object: In Javascript, an object is a thing defined using attributes and methods.
🌐
WsCube Tech
wscubetech.com › resources › javascript › data-types
JavaScript Data Types: Primitive & Non-Primitive With Examples
November 5, 2025 - Learn about JavaScript data types: Primitive & Non-Primitive with examples. Explore strings, numbers, objects, arrays, and more in this comprehensive guide.
🌐
Edureka
edureka.co › blog › data-types-in-javascript
What are the Different Data Types in JavaScript - Edureka
February 11, 2025 - Primitive data types are number, string, boolean, NULL, Infinity and symbol. Non-primitive data types is the object. The JavaScript arrays and functions are also objects.
Top answer
1 of 7
4
Data Types (JavaScript):

Primary Data Types
The primary (primitive) data types are:
String, Number, Boolean

Composite Data Types
The composite (reference) data types are:
Object, Array

Special Data Types
The special data types are:
Null, Undefined

Click here for details:

  var test1 = 1;
  var test2 = "Something";
  var test3 = true;
  var test4 = {};
  var test5 = new Array();
  var test6 = new Date();
  var test7;
  var test8 = null;

  alert(typeof (test1)); //number
  alert(typeof (test2)); //string
  alert(typeof (test3)); //boolean
  alert(typeof (test4)); //object
  alert(typeof (test5)); //object
  alert(typeof (test6)); //object
  alert(typeof (test7)); //undefined
  alert(typeof (test8)); //object
2 of 7
4

Javascript has five primitive data types: 1. number 2. string 3. boolean 4. undefined 5. null

Anything that doesn’t belong to any of these five primitive types is considered an object.

First 3 data types has a corresponding object constructor. For example

var word = "something";

And then as an object:

 var word = new String("something");

For object constructor notice the new keyword. It creates object reference.

Another thing to notice that

var greeting = "something";
var word = new String("something");
greeting == word ----> True as their value is same
greeting === word -----> False because there value same but type is different .

As for var keyword being same for all the cases,remember that Javascript is dynamically typed language. That means it resolves data type checking during runtime rather than compile time(like Java, C++ ).

This makes javascript extremely powerful. Though this unique feature has drawback too. Please co through this wikipedia for details: https://en.wikipedia.org/wiki/Type_system#Static_and_dynamic_type_checking_in_practice

Hope this helps.

Find elsewhere
🌐
Medium
medium.com › @Harshit_Raj_14 › data-types-in-javascript-d8ea72dd3ca9
Data Types in JavaScript. In JavaScript, data types are broadly… | by Harshit Raj | Medium
March 3, 2023 - Arrays are another common non-primitive data type in JavaScript that are used to store ordered collections of data in a single variable. They can be created using the square brackets [] syntax. Arrays can contain any data type, and the elements are indexed by number starting from 0. ... We can access individual elements of the array using the index number. For example, fruits[0] would return "apple".
🌐
ScholarHat
scholarhat.com › home
Data Types in JavaScript: Primitive & Non-Primitive
September 22, 2025 - In this JavaScript tutorial, we'll ... with examples and the typeof operator in detail. To master these concepts and more, you can enroll in a Free Online JavaScript Course and enhance your learning experience! The ES6 version introduced in 2015 defines eight standard data types in JavaScript. The eight basic data types in JavaScript are classified into two categories: Primitive data types are predefined or built-in data types in JavaScript that can hold simple values. Non-Primitive ...
🌐
W3Schools
w3schools.com › js › js_datatypes.asp
JavaScript Data Types
JavaScript Objects represent complex data structures and functionalities beyond the primitive data types (string, number, boolean, null, undefined, symbol, bigint).
🌐
DEV Community
dev.to › js_catch › 02-primitive-and-non-primitive-data-types-in-javascript-2dhd
02 - Primitive and Non-Primitive Data Types in Javascript - DEV Community
July 2, 2020 - After which the special object is destroyed, leaving the primitive str alone. ... let arr = [ 'one', 'two', 'three' ]; arr[0] = 'ONE'; console.log(arr) // Output -> [ 'ONE', 'two', 'three' ] In example 4 we are mutating the state of variable arr and changing the value itself as value at index 0 is changed from one to ONE · typeof operator returns a string that tells the type of a JavaScript variable.
🌐
MSR
rajamsr.com › home › top 6 non primitive data types in javascript
Top 6 Non Primitive Data Types In JavaScript | MSR - Web Dev Simplified
February 29, 2024 - Discover the non-primitive data types in JavaScript, including Arrays, Maps, Sets, WeakMaps, and WeakSets with examples.
🌐
Medium
medium.com › @dulshansagara6 › lesson-04-understanding-non-primitive-data-types-in-javascript-75f9997283db
Lesson 04: Understanding Non-Primitive Data Types in JavaScript | by Dulshan Senadheera | Medium
July 13, 2024 - Lesson 04: Understanding Non-Primitive Data Types in JavaScript In JavaScript, while primitive data types form the foundation, non-primitive data types allow for more complex data structures and are …
🌐
DEV Community
dev.to › thecharacterv › defining-primitive-and-non-primitive-data-types-in-javascript-40gk
Defining Primitive and Non-Primitive Data Types in JavaScript - DEV Community
January 15, 2021 - Here we are setting favoriteBird equal to birdBreed. When we reassign favoriteBird with a different value, it does not effect the value of birdBreed. This is what we would expect to happen! This is an example showing immutability. You will see later that this is not the case for non-primitive data types.
🌐
TutorialsPoint
tutorialspoint.com › what-are-primitive-and-non-primitive-data-types-in-javascript
What are Primitive and Non-Primitive Data Types in ...
In addition to these primitive data types, JavaScript supports a composite data type known as object. We will cover objects in detail in a separate chapter. The Object data type contains the 3 sub-data types − ... In any programming language, data types are important for operation manipulation. For example, the below code generates the 1010 output.
🌐
CodeSweetly
codesweetly.com › javascript-non-primitive-data-type
Non-primitive Data Type – What Is a JavaScript Object? | CodeSweetly
An object is a non-primitive JavaScript component that you can use to bundle multiple items into a single one. Objects allow you to store multiple items into a JavaScript variable—which can accept only a single element. ... Keep these three essential pieces of info in mind whenever you choose to use JavaScript objects.
🌐
TutorialsTeacher
tutorialsteacher.com › javascript › javascript-data-types
Overview of Data Types in JavaScript
Example: A Variable with Different Types of Data Copy · let myvariable = 1; // numeric value myvariable = 'one'; // string value myvariable = true; // Boolean value ... In the above example, different types of values are assigned to the same variable to demonstrate the loosely typed characteristics of JavaScript. Here, 1 is the number type, 'one' is the string type, and true is the boolean type. JavaScript includes primitive and non-primitive data types as per the latest ECMAScript 5.1 specification.
🌐
Hyperskill
hyperskill.org › university › javascript › javascript-data-types
JavaScript Data Types
July 22, 2024 - Modulus (%): Returns the remainder of a division operation between two numeric values. Example: 4 % 2 = 0 · When these arithmetic operators are applied to non-primitive data types, such as strings, JavaScript may attempt to convert the values to numbers before performing the operation.
🌐
EyeHunts
tutorial.eyehunts.com › home › primitive vs non-primitive data types in javascript
Primitive vs non-primitive data types in JavaScript
March 22, 2023 - <!DOCTYPE html> <html> <body> <script> //primitive data types let name = 'John'; // string let age = 30; // number let salary = 50000n; // bigint let isStudent = false; // boolean let car = undefined; // undefined let home = null; // null console.log(name); console.log(age); console.log(salary); console.log(isStudent); console.log(car); console.log(home); // non-primitive data types let person = { name: 'John', age: 30, isStudent: false }; // Object let fruits = ['apple', 'banana', 'orange']; // Array function sayHello(name) { console.log(`Hello ${name}!`); } // Function console.log(person); console.log(fruits); console.log(sayHello); </script> </body> </html> ... Comment if you have any doubts or suggestions on this JS datatype topic. Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.