03:06
<sideshowbarker>
Looking at https://github.com/mdn/content/issues/15129 — in general in MDN articles where we’re describing a case where some JavaScript data type gets coerced into another data type, any recommendations on what term we should use? “an x gets cast to a y”, or “an x gets converted to a y”, or “an x gets coerced into a y”? or what?
(this particular case is about the delay parameter of setTimeout() being coerced into a number)
03:07
<bakkot>
"coerced" is the term I personally use
03:07
<jmdyck>
The spec doesn't use the verb "cast" at all.
03:08
<bakkot>
this is also the word used in at least some education materials, looks like
03:08
<sideshowbarker>
The spec doesn't use the verb "cast" at all.
OK yeah then I think we should avoid “cast” in MDN
03:09
<bakkot>

e.g. https://eloquentjavascript.net/01_values.html

When an operator is applied to the “wrong” type of value, JavaScript will quietly convert that value to the type it needs, using a set of rules that often aren’t what you want or expect. This is called type coercion.

03:09
<jmdyck>
It does use "coerce" some, but it uses "convert/conversion" a lot more.
03:09
<bakkot>
though that's in a section called "automatic type conversion", not "... coercion", so somewhat inconsistent
03:10
<bakkot>
also e.g. https://exploringjs.com/impatient-js/ch_values.html#coercion-automatic-conversion-between-types
03:10
<sideshowbarker>
OK, I see now we actually have https://developer.mozilla.org/en-US/docs/Glossary/Type_coercion in MDN
03:11
<sideshowbarker>

Type coercion is the automatic or implicit conversion of values from one data type to another (such as strings to numbers). {{Glossary("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.

03:12
<jmdyck>
So if a particular case is implicit, how are you supposed to decide if it's coercion or conversion?
03:13
<sideshowbarker>
dunno…
03:16
<jmdyck>
Hm, some of the spec's uses of "coerce" are not implicit. e.g. "A String object can be coerced to a String value by calling the String constructor as a function"
03:18
<jmdyck>
I think the spec is using "coerce" and "convert" interchangeably.
03:57
<sideshowbarker>
They’re likely used interchangeably in MDN articles as well — I doubt most MDN contributors make the distinction