JavaScript Data Types for Absolute Beginners

What is a Data Type?


Fahad Khan

2 years ago | 2 min read

JavaScript is the dynamically typed or loosely typed programming language because we can mix the types of data into a single variable. This article is for newbies who want to learn JavaScript and its fundamentals.

This article is about JavaScript data types. Each programming language has its own data types and a way of declaring them. The same is the case with JavaScript. Data types are also a relevant topic for “data structures”, which is for more advanced programmers. But in basic terms, selecting the right data type for the right application is important. Here, we’ll stick to covering data types.

What is a Data Type?

This is the basic question — what exactly is a data type?

Data is a raw form of information and types refer to the variety of types this information may be conveyed in. Let’s make it more simple.

Suppose you’re in the library and you’re looking for a book named “Fundamentals of Computer Science”. Now, the name of the book is the data & its type is Computer Science which means this book is related to the Computer Science field.


An even simpler example of data type:

Let’s imagine you have $1 (1 US Dollar). Technically, you have a data with a certain type — “$1” is the data and its currency is the type which, in this case, is “dollar”.

Now, we know what we mean by data types.

How many data types are there in JavaScript?

JavaScript broadly supports two types of data, they are:

  • Primitive Type
  • Reference Type

Primitive Type:

Primitive data types don’t require a large amount of data for representation. Primitive data types in JavaScript are:

  1. String (“Fahad”, “Khan”, “Sameer”)
  2. Number (1, 2, 22, 33)
  3. Boolean (“True” / “False”)
  4. Undefined
  5. Null
  6. Symbol
  7. BigInt

Reference Type:

  1. Array
  2. Function
  3. Object

Now, let’s see them in the code below:

let str = "JavaScript -String";

let num = 123;

let UserLoggedIn = false;

let intialAmount = undefind;

let balance = null;

let id = Symbol("123-AGDS-213");

const alsoHugeNumber = BigInt(9007199254740991);
// ↪ 9007199254740991n

//NOTE: you can use "typeof()" opertor to know the data type
//ex: console.log(typeof(str)) => String

const person = {
name: "Fahad Khan",
age: 24,
id: 33,
roll: "2K17/CSE/33"

const list = ["Fahad Khan", 24, 33, "2K17/CSE/33"];

function addNumbers (num1, num2){
return num1 * num2;

Data Types in JavaScript

As you can see, in JavaScript, all your data will be rendered using these types, regardless of what type of application you may be building.

Moreover, these types are basic data types but are very powerful because data structures in JavaScript are built using these types.

This article was only meant as an instruction to data types. But remember! There’s more to the story. There are many predefined methods available in JavaScript to interact with your data types such as String and Array methods.

So, this was a very quick view of data types. After reading this you must learn how to manipulate these data types with predefined and custom methods.

Thanks for reading. If you have any questions, I’ll be happy to answer them for you.


Created by

Fahad Khan







Related Articles