2 min read

[4] What is data?

Every language has different ways of differentiating data. In JavaScript we break it down like such.
[4] What is data?
Photo by Patrick Lindenberg / Unsplash

By now you have heard the term data thrown around. What is it? Like really, and how do we use it as software developers?

We would use data, like names, addresses, bank account numbers to write financial software for example. When it comes to coding that data comes in two forms, in databases or in variables. We will leave databases alone for the moment and just focus on the later.

We have previously explored variables like in our Pythagorean Theorem example. There were variables like a and b and c. Each of these variables held a value, and that value was our data. Yes, data is that simple. In a basic, practical concept, data is just values of variables.

Although data is that simple, there is some complexity to how we interact with certain kinds of data. Every language has different ways of differentiating data. In JavaScript we break it down like such.

There are two high level categories of data: primitive and complex data.

Within the primitive category we have number, string, boolean, null, undefined, bigint, and symbol. For the rest of these articles, we will be ignoring the last two data types that I referenced as they are used in very specific and advanced use cases. (I myself have not yet used them in a professional project)

For the complex category we have object and array.

We will dive into each of these data types in the coming articles but for now let me preface with some background of JavaScript data types and major differences it has with most other programming languages.

In most programming languages, when you declare a variable, you also need to declare what data type that variable will hold; be it a number, a word or phrase, etc. Throughout the program that variable will always need to remain that data type. However, in JS, we do not need to declare the data type of a variable, and when we want to change the value of a variable, we can change it to any other data type that we like.

For instance:

let name = 'Joshua'
console.log(name) // would log out Joshua
name = 30
console.log(name) // would print out 30 with no error.

This feature of the language come with great power over how your code operates. Yet, remember Uncle Ben "comes great responsibility". Chaning data types with no discipline can lead to confusing code that is hard for a teammate (or your future self) to follow. I will spend my efforts, to the best of my ability, ignoring this feature of the language throughout these articles.

With this basic introduction, let's move to the next article where we will go over the basic data types in JavaScript.