Creating classes has a special syntax, using the class
keyword
WHEN creating a class XXX
THEN writing class XXX {}
is the most common way
WHEN assigning class {}
to a variable THEN this an anonymous class
constructor, methods and other class fields
WHEN instantiating a class THEN the method named constructor
is executed
WHEN instantiating a class and passing arguments THEN the constructor receives them
WHEN defining a custom method THEN this can be done like the constructor
, using a custom name
WHEN defining multiple methods THEN these can be written in any order without any special separation characters
GIVEN one creates a class using a class expression
WHEN using a class expression without a name THEN the name is derived from the variable name
WHEN using a class expression with a name THEN the name is that name
Links
Required Knowledge
- `const` declaration (Block scope)
- `function.name` (function API)
Related Katas
Class
Difficulty Level
BEGINNER
First Published
14 April 2015
Stats
8 tests to solve