So data types, what are they? Are they essential? Yes, they are, and you must know about data types.
- Datatypes are something familiar in all programming languages
- This is very convenient as we don't have to declare a data type when we create a variable.
- If you want to store some exemplary texts in a variable, the string is your best pal.
var name = 'Mario' console.log(typeof(name))
var number = 2000000 var fl = 22.33 var ex = 40e5 console.log(typeof(number) ,typeof(fl), typeof(ex))
number number number
- So boolean is a datatype that points in the direction of yes/no.
- Think of it as a switch between yes and no.
- So basically represented by true or false.
var orderDelivered = true; var notDelivered = false;
- Undefined is where we declare a variable, and if we don't assign values to that variable, it'll automatically throw it as undefined.
- This means it has no value to it currently because of the unassignment.
let matrix; console.log(matrix)
- Null is an empty pot without any water in it waiting to be filled up anytime later.
- It is a variable with an empty value, or we can say it is an unknown value.
let matrix2 = null; console.log(matrix2)