JavaScript #9 — Variables Types
These JavaScript articles are written for people who are interested in coding and are meant to provide an introduction to the programming world.
You are going to learn what are the primitive types in Javascript.
Variable Types
There is a couple of primitive types in JavaScript. The main primitive types in JavaScript are:
- undefined — indicates that value is not provided, so the type cannot be identified
- number — a type of variable stores a whole or decimal number
- text —a type of variable stores a string value
- boolean — type of variable stores
true
orfalse
values
The primitive types are defined as raw types that are the basic building blocks of a programming language.
Empty variables
Empty variable or undefined variables have undefined
value. An undefined
value is of the undefined
type.
<script>
let name1
let name2 = undefined console.log(name1)
console.log(name2)
</script>
Try to run the code above.
Final words
This was a short introduction to different types of variables in JavaScript. The next steps are to explore numeric, string, and boolean variables.