Sumit | Javascript + React
Sumit | Javascript + React

@sumitsaurabh927

10 Tweets Mar 02, 2023
๐Ÿ“Œ Javascript data types!
๐Ÿงต A thread: ๐Ÿ‘‡
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
Primitive data types are of seven further types:
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 ๐Ÿ‘‡
Number and BigInt:
Numbers represent all numbers whether or floating point (decimal).
BigInt is used to represent really large numbers, which can't be represented by 'Number' due to memory limitations.
One thing to note - Numerical values such as 'Infinity' are also 'Number'.
String:
Strings can be broadly understood as text. There are three ways to write a string:
1. Single quotes
2. Double quotes
3. Backticks
When using backticks we can also embed variables inside the text as shown:
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.
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'.
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.
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! ๐Ÿงก๐Ÿงก๐Ÿงก

Loading suggestions...