19:25
<sideshowbarker>
looking at https://github.com/mdn/content/pull/11683
19:26
<sideshowbarker>
The existing statement “Function expressions in JavaScript are not hoisted” in MDN is correct, right?
19:46
<Ashley Claymore>

correct.

console.log(foo) // ReferenceError
void function foo() {}
19:48
<nicolo-ribaudo>
Functions expressions do not need to be hosted because their binding is only visible inside their body, and no code can run before that binding initialization.
19:48
<nicolo-ribaudo>
I dislike @[Ashley Claymore]'s example, because swapping the two statements doesn't remove the error
19:50
<bakkot>
yeah it's more precise to say that 'hoisting' is not a thing which applies to expressions
19:50
<Ashley Claymore>
fair 🙂 I was going for a minimal way to write a function expression
19:51
<Ashley Claymore>
💯 agree that showing that there is no external binding at all is the more important core
19:53
<nicolo-ribaudo>
looking at https://github.com/mdn/content/pull/11683
Looking at this PR, it looks like the contributor confuses the function expression with the variable declaration. It's not that function expressions are hosited like var declarations: it's just the variable which is hoisted.
19:54
<Ashley Claymore>
Yeah, maybe it’s not clear to them that only the RHS is considered the function expression. Maybe an ast-explorer link would help
20:07
<sideshowbarker>
nicolo-ribaudo: Ashley Claymore Thanks — I added a comment at https://github.com/mdn/content/pull/11683#issuecomment-1004327053 that goes into a bit more detail.
20:08
<sideshowbarker>
I cited https://stackoverflow.com/questions/3887408/javascript-function-declaration-and-evaluation-order/3887590#3887590 — which seems like a really good explanation in detail of what actually happens.
20:12
<sideshowbarker>
Thanks bakkot as well