How JavaScript type coercion works