Data types are one of the fundamental topics in Javascript and we'll be taking a look at the same today.
There are primarily two data types in Javascript - Primitive and Non-primitive
There are primarily two data types in Javascript - Primitive and Non-primitive
Primitive data types are of seven further types:
1. Number
2. BigInt
3. String
4. Boolean
5. Symbol
6. Undefined
7. Null
1. Number
2. BigInt
3. String
4. Boolean
5. Symbol
6. Undefined
7. Null
Non-primitive data type is just one - Object.
There are different kinds of objects such as:
- Functions
- Arrays
- Date etc
In fact, there's a good chance in Javascript that anything that is not primitive is an object.
Let's look at each in detail below ๐
There are different kinds of objects such as:
- Functions
- Arrays
- Date etc
In fact, there's a good chance in Javascript that anything that is not primitive is an object.
Let's look at each in detail below ๐
Boolean:
Booleans are simple yes/no type variables that can either be yes or no and nothing else.
They are quite useful when dealing with conditional logic and with logical operators.
Booleans are simple yes/no type variables that can either be yes or no and nothing else.
They are quite useful when dealing with conditional logic and with logical operators.
Symbol, Undefined and Null:
Each of these has specific use cases.
Symbols are used to create unique and private ids.
Undefined is used to denote 'value not assigned', and
Null is a reference to an object that doesn't exist. It represents 'nothing'.
Each of these has specific use cases.
Symbols are used to create unique and private ids.
Undefined is used to denote 'value not assigned', and
Null is a reference to an object that doesn't exist. It represents 'nothing'.
Objects:
The only non-primitive data type is the object.
You may have heard that in JS, everything is an object.
And it's true.
Functions, arrays, etc are all objects.
In JS, functions aren't a special type of data structure, they're a special type of object that we can all.
The only non-primitive data type is the object.
You may have heard that in JS, everything is an object.
And it's true.
Functions, arrays, etc are all objects.
In JS, functions aren't a special type of data structure, they're a special type of object that we can all.
That's a wrap!
If you enjoyed this thread:
1. Follow me @sumitsaurabh927 for more of these
2. RT the tweet below to share this thread and show me some love! ๐งก๐งก๐งก
If you enjoyed this thread:
1. Follow me @sumitsaurabh927 for more of these
2. RT the tweet below to share this thread and show me some love! ๐งก๐งก๐งก
Loading suggestions...