Data types in JS

Pay attention ▲, this post will teach you whatever you need to understand what are data types and how can you select the type you need to accomplish your target 🥳.

First of all you need to understand that JS is dynamic typed, if you read our all post …


This content originally appeared on DEV Community and was authored by Manu Martinez

Pay attention ▲, this post will teach you whatever you need to understand what are data types and how can you select the type you need to accomplish your target 🥳.

First of all you need to understand that JS is dynamic typed, if you read our all post you have already known what does it mean 😋.

Dinamic typed ❤️

OMG!!, It sounds really crazy, it sound really difficult but no, if you think in the sense of dynamic you will understand that typed are assign in *execution time *, it means that when you are writing your code you won't need to indicate what are exactly the types 😏. It's one of the most clearly advantage if you are learning JS as a first programming language.

Then 😇, Why must I know what are data types if JS makes implicit assignations?

You really need to know what types of data do you have available, because you can prepare your code to work with those. Let's going to start with the simple data 😏

  • String -> It means literally chars chain, for example word is a string because it's text. This data type is composed by quotes, doesn't care, double, simple, accent whatever, the main important think is put the text inside the quotes.
console.log("My first string")
  • Number -> Like his name said, it's a number, a pointing number, a real number, whatever that means exactly a Real Number.
let myAge = 15
  • Boolean -> It means true or false, easy isn't it 🤓?, it only indicates a state, it's one of the most important data type, since, you will need to control the execution steps thankfully to Boolean values.
let truth = true
let ohh = false
  • Null -> It can be really confuse, it means that you have created a value that will be change soon and first you assign to null. One of the most important uses is to indicate when a function get an error, normally you will return null when there was a failure in the execution time.
let myNull = null
myNull = "Hola"
console.log(myNull)
  • Undefined -> It appears when you declare a var and you don't assign any value. It usually appears when you try to get a value from any var/let/const which has never been defined. It's usually identified such a developer error.
let a;
console.log(a) // it prints undefined

I know, 😊 there are more data types, means more complex data types, but the basic data types are all of above. Really, it's so important to understand what are exactly each one, you need to know what are the difference 😉 and how to use it.

In the following post we will deep into more detail about complex data types, understanding what does it mean. For now, I strongly recommend you to study and research more about data types, you can write down your own personal notes and use it for remembering all data types 😤.


This content originally appeared on DEV Community and was authored by Manu Martinez


Print Share Comment Cite Upload Translate Updates
APA

Manu Martinez | Sciencx (2021-12-06T09:06:36+00:00) Data types in JS. Retrieved from https://www.scien.cx/2021/12/06/data-types-in-js/

MLA
" » Data types in JS." Manu Martinez | Sciencx - Monday December 6, 2021, https://www.scien.cx/2021/12/06/data-types-in-js/
HARVARD
Manu Martinez | Sciencx Monday December 6, 2021 » Data types in JS., viewed ,<https://www.scien.cx/2021/12/06/data-types-in-js/>
VANCOUVER
Manu Martinez | Sciencx - » Data types in JS. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/12/06/data-types-in-js/
CHICAGO
" » Data types in JS." Manu Martinez | Sciencx - Accessed . https://www.scien.cx/2021/12/06/data-types-in-js/
IEEE
" » Data types in JS." Manu Martinez | Sciencx [Online]. Available: https://www.scien.cx/2021/12/06/data-types-in-js/. [Accessed: ]
rf:citation
» Data types in JS | Manu Martinez | Sciencx | https://www.scien.cx/2021/12/06/data-types-in-js/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.