Are the statements:
let a;
and
let a=undefined;
ever any different? Do they always compile to the same code in node and/or the browser?
A variable defined by a LexicalBinding with an Initializer is assigned the value of its Initializer's AssignmentExpression when the LexicalBinding is evaluated, not when the variable is created. If a LexicalBinding in a let declaration does not have an Initializer the variable is assigned the value undefined when the LexicalBinding is evaluated.
Where initializing let runs either the step:
Perform ? InitializeReferencedBinding(lhs, undefined).
(in the case of LexicalBinding : BindingIdentifier), or the step
Perform ? InitializeReferencedBinding(lhs, value).
where value is what's on the right-hand side of the =.
I suppose one very strange situation where they could be different is if someone created another identifier named undefined, but in any remotely sensible code, that shouldn't be seen.
{
const undefined = 5;
let a = undefined;
console.log(a);
}