codemarch
codemarch

@codemarch

11 Tweets 9 reads Sep 05, 2022
Learn JavaScript Type Conversions
The Complete Guide:
Thread 🧵
Type conversion is the process of converting data from one type to another in programming. For instance, consider converting String data to Number.
There are two types of type conversion in JavaScript.
🔹 Implicit Conversion- automatic type conversion
🔹 Explicit Conversion- manual type conversion
JavaScript Implicit Conversion
JavaScript automatically converts one data type to another in certain situations (to the right type).
Example 1: Implicit Conversion to String.
Example 2: Implicit Conversion to Number.
JavaScript Explicit Conversion
You can also convert one data type to another as per your needs.
In JavaScript, explicit type conversions are done using built-in methods.
1. Convert to Number Explicitly
To convert numeric strings and boolean values to numbers, you can use `Number()`.
For example,
2. Convert to String Explicitly
To convert other data types to strings, you can use either `String()`or `toString()`.
For example -
3. Convert to Boolean Explicitly
To convert other data types to a boolean, you can use `Boolean().`
If you enjoyed reading this thread, please do the following:
1. Like the thread❤️
2. Retweet the first tweet.🔃
3. Follow me and enable notifications: ✅
@CodeMarch
Thank you for reading all the way through.
Download our free JavaScript Resources ebook Here:
codemarch.gumroad.com

Loading suggestions...