π· About Javascript Type conversion in brief β
A Thread 𧡠:
What is type conversion?
It is exactly what the name states, conversion of one type to other.
: string to integer
: integer to string etc.
Javascript allows us to do the same with some easy functions.
As we know, there are 3 main primitive data types in Javascript namely:
~ string
~ number
~ boolean
How to check the type of a specific data?
Let's say we have β
How to determine the type of data? β
But you will not get a certain data type always, sometimes when the engine isn't sure about a primitive data type, it logs this β
How does type conversion take place in Javascript?
These are the methods mainly used:
There is a concept called Operator Precedence.
Different operators have different precedence and javascript doesn't treat each operator as the same!
So what exactly is the order?
1. () = has the most important precedence in JS 2. . = the dot operator has the 2nd most 3. [] 4. ?. = if else bracing 5. new = with arguments and then without arguments!
I believe in learning by actually coding and not only reading.
Want all these code snippets and readymade code to work on?