How does this javascript factorial function work?

Factory Function

When a function returns an object, we call it a factory function. It can produce object instance without new keywords or classes.

Ex:-

Factory Function with Parameter

Ex:-

Tagged : / / /