You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Should class declarations contain a binding for class name in the scope for the class?
Klass in example below has 2 bindings - 1st at top level, 2nd within the class body.
classKlass{statictryWrite(){Klass=123;}}constCopyOfKlass=Klass;// Reassignment of `Klass` in top level scope succeedsKlass=123;console.log(Klass);// Logs 123// Reassignment of `Klass` within class fails.// `TypeError: Assignment to constant variable at Klass.tryWrite`CopyOfKlass.tryWrite();
The outer binding is reassignable, whereas the binding within the class is read-only.