What is the Difference Between Data Type and Data Structure?
Tags: javascript, beginners, programming, tutorial
Published: 2023-01-27 13:09:56

In JavaScript, there are many terms and explanations that sound so similar to each other that for a beginner it can become a little confusing. And it is definitely confusing because the definitions are sometimes exactly the same but the last word in the description is a little different!

Today, I will try to break down the difference between data types and data structures so we can move on to data types and data structures in JavaScript in more detail which is a crucial topic in JavaScript.


![Definition](https://media1.giphy.com/media/VML2lNolrKpP5sQvUn/giphy.gif?cid=ecf05e479qd9cq7028lugdyteht0ez4ws9s3zgnx9e9ltemy&rid=giphy.gif&ct=g)

## Definition

The data type is a categorization of specific types of values on which we can perform the same operations. It’s like having a specific label to tell the computer what data we are giving to it. This helps the computer to understand what to do or what can be done with the data so it can respond with a correct result. If let’s say I told the computer to calculate the sum of a letter and a number it wouldn’t understand what to do if it didn’t know that one is a number and the second is a letter.


Data structure however is a collection of various data types. It makes it easier to organize, find or manipulate data when they are organized in a specific order or place.
So it’s a group of data types labeled and organized in a specific way.


![What does it store?](https://media4.giphy.com/media/GbH8vRmrNHdVZhouBt/giphy.gif?cid=ecf05e471tq5jfi71aursco13yl8m4zinxs1viv0267lvsr1&rid=giphy.gif&ct=g)

##  What does it store?

Data type stores a specific type of data that can vary. It can be letters or numbers and some other values. For example, we can have different data types in clothing like dresses, t-shirts, skirts, and so on.
Data type also can store particular values. So if I have a data type for clothing, I will not be able to store vegetables there.

Data structure however store the data types but specific collections of these data types. Just like in clothing, we can create a data structure for summer clothing that holds different types of clothing types but are specific only for summer.
The data structure can store any type of data in the same structure and doesn’t have to be the same as in data types.



![How do we save values?](https://media3.giphy.com/media/U23WekMlGy6cImpMim/giphy.gif?cid=ecf05e47ep6l8h96bhqbf6ac9mwoh8mk7vvrsnjw0tnvixrr&rid=giphy.gif&ct=g)
## How do we save values?

In data types we usually save values directly and don’t have to create data types, they already are predefined. In some languages however, you have to indicate what exact predefined data type it is going to hold in the future while in another language the data type is indicated the moment we assign it a value.  In JavaScript when I assign a number value, the data type is defined at that moment and I do not have to write in advance that it will hold a number value.

In the data structure, you cannot just assign value, because it is a type of box that has other boxes inside it sometimes, not just a label. So there are different types of operations we perform to push the information to the data structure. Something similar to adding things to the box, e.g. remove, add, and so on.



![Difference across languages](https://media3.giphy.com/media/jVZJsyEXEMPYBBJHLZ/giphy.gif?cid=ecf05e47cv8654f9b0r40r3wy5qwk3d202au3qt0hyaa5ftg&rid=giphy.gif&ct=g)
## Difference across languages

Both data types and data structures can vary depending on the programming language. Some languages have similar data types of data structures and some have ones that others don’t. However, we are going to discuss JavaScript data types and structures in the next posts!


**📌 Enjoyed the post? Please let me know in the comment down below!**