PRIMITIVE to me means BASIC! Like a caveman...and you literally cant build anything without basic data. primitive data type is data that is not an object and has no methods.
Some of the Primitive data types:
- NUMBERS
- STRING
- BOOLEAN
- UNDEFINED
- NULL
Examples of Javascript numbers
100 //Integers
50
1.1 //Floats
100.69
Examples of Javascript strings
"Hi!" //you can define a 'string' by double quotes.
'Hi!' //you can also define a 'string' by single quotes.
"30" // this is also a string
Examples of Javascript booleans
true // Booleans only state is 'true' or 'false
false // It is either on or off, yes or no!!
Examples of Javascript null & undefined
// null means that there is no value assigned..empty
// and is intentionally set
// undefined means that the container exists
// but hasnt been given a value
console.log(null === undefined); //false
console.log(null == undefined); // true
Another day in the life using primitive data types in a loop
//while some number is less than 10, console.log('string type')
let i = 1;
// while something is true..run this scoped code
while (i < 10) {
console.log('string type', i)
i += 1 // i = i + 1
}
Top comments (1)
Good start.