Class Name binding

suggest change

A class declaration's name is bound differently in two scopes:

  1. Where the class is defined, the binding is like let: it can be reassigned, and it has a temporal dead zone.
  2. Inside the class body, the name is a const binding. Methods close over that inner binding.
class 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 in non-strict code; strict mode throws
}
A.prototype.foo = function foo() {
  A = null; // works
}
A = null; // works

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents