what is type coersion | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

what is type coersion

example also please.

22nd Nov 2022, 5:01 PM
Sunil Shrestha
Sunil Shrestha - avatar
2 Answers
+ 3
"Type coercion is the automatic or implicit conversion of values from one data type to another (such as strings to numbers). Type conversion is similar to type coercion because they both convert values from one data type to another with one key difference — type coercion is implicit whereas type conversion can be either implicit or explicit." Source: https://developer.mozilla.org/en-US/docs/Glossary/Type_coercion Type casting is an explicit form of type conversion. With coercion, the types are converted implicitly, that means you are not spelling out in the code that you want the type changed, but the javascript interpreter will have no other choice, for example if you try adding a string and a number.
22nd Nov 2022, 9:48 PM
Tibor Santa
Tibor Santa - avatar
+ 1
is it same like type casting
22nd Nov 2022, 5:02 PM
Sunil Shrestha
Sunil Shrestha - avatar