In JavaScript 2.0 we define classes using the class keyword. Limited classes can also be defined via JavaScript 1.x-style functions , but doing so is discouraged for new code. Identifier is a constant variable with type type and can be used anywhere a type expression is allowed. If extends TypeExpression is given, TypeExpression is evaluated to obtain a type s , which must be another class. If extends TypeExpression is absent, type s defaults to the class Object .
Type t is made a subtype of type s .
Block is evaluated. The value of Identifier becomes type t . From now on Identifier is a constant and its value cannot be altered. A ClassDefinition 's Block is evaluated just like any other Block , so it can contain expressions, statements, loops, etc. Such statements that do not contain declarations do not contribute members to the class being declared, but they are evaluated when the class is declared.