ClassDeclaration's Name is bound in different ways in different scopes -
let
binding{
and }
in class {}
- const
bindingclass Foo {
// Foo inside this block is a const binding
}
// Foo here is a let binding
For example,
class A {
foo() {
A = null; // will throw at runtime as A inside the class is a `const` binding
}
}
A = null; // will NOT throw as A here is a `let` binding
This is not the same for a Function -
function A() {
A = null; // works
}
A.prototype.foo = function foo() {
A = null; // works
}
A = null; // works