Data type in javascript
The data types are kinds of data that we can use to create program, javascript has two data types the first one is primitive and the second one is object.
The primitive data types
Javascript has 6 kinds of primitive data types:
- Number: floating, decimals and integers, Javascript always write numbers in decimals (5.0 for example).
- String: Sequence of character, used for text.
- Boolean: Can take two values
true
orfalse
. - Undefined: Assigned to variable with no value.
- Null: Display when you call something who don't exist.
Examples
let decimal = 5.0;
let number = 5;
let nom = 'lucas';
let booleanTrue = true;
let booleanFalse = false;
let undefined;
- Numbers floating should be written with a
.
and not a,
. - The string data types should be surrounded of '' or "" .
- Use
true
orfalse
to declare boolean. - In the last variable we declare a variable with no value if we try to call her we will have
undefined
as result.
Note: Javascript is dynamic typing which means that it automatically recognize which kind of data you're using, instead of language like C or you have to declare data types.
The object data types
In computer an object is a value store in the memory of the computer who can be access by an id.
Note: click here to see how to use object.
Current errors
This is a list of the main errors that you can meet when you use data types:
Note: I'm not a wizard there is maybe some issue that you notice above so fell free to open an issue in the github repo if you find a new error not mentioned above.