To define each of the set classes as a property of the sets object

to-define-each-of-the-set-classes-as-a-property-of-the-sets-object

To define each of the set classes as a property of the sets object (namespace) for the module, the statement is

A. sets = sets.AbstractEnumerableSet.extend();

B. sets.SingletonSet = sets.AbstractEnumerableSet.extend(…);

C. sets.SingletonSet = sets.extend(…);

D. sets = sets.extend(…);

This question was posed to me during a job interview.

The origin of the question is Modules in JavaScript topic in portion Classes and Modules in JavaScript of JavaScript

The correct answer is B. sets.SingletonSet = sets.AbstractEnumerableSet.extend(…);

To explain I would say: Singleton is an object which can only be instantiated once. The extend keyword is used in class declarations or class expressions to create a class which is a child of another class. The sets object is the namespace for the module, and we define each of the set classes as a property of this object.