Saved Bookmarks
| 1. |
What is Type Coercion in JavaScript? |
|
Answer» The term type coercion refers to the PROCESS of converting VALUES from one data type to another, either automatically or implicitly. For instance, you could convert a NUMBER to a string, a string to a number, or a boolean to a number, etc. Example: Number to String Conversion <script> // The Number 5 is converted to // string '5' and then '+' // concatenates both strings const VALUE1 = 5; const value2 = '50'; var x = value1 + value2; document.write(x);</script>Output: 550The above example SHOWS how JavaScript converted the number 5 into a string and concatenate the values together, resulting in 550. |
|