DEV Community

Discussion on: Variable explanation help:

Collapse
 
dovey21 profile image
Somtochukwu Nnaji • Edited

Coercion happens when you try to join two different values (values like string and Number) together e.g
When you something like this

let age = 12;
let myName = "dovey";
const result=age + myName;
console.log(result)

the result would be 12dovey javascript engine noticed that they both are not of the same value and can not be joined together to get an appropriate mean so it had to coerced i.e forcefully joining them together to get a result.