Hacker News new | ask | show | jobs
by 1718627440 283 days ago
> a factory can vary the return type, unlike a plain constructor

That's a language limitation and has nothing to do with the design pattern. You can do this just fine e.g. in Python.

1 comments

You could do that more or less in Javascript by creating and initializing different member variables in the constructor depending on a constructor argument but I would hate you for it.