[javascript] Factory Method Pattern (1)