JS factory pattern first approach