Skip to content

JS: Factory functions #37

@mkermani144

Description

@mkermani144

Description

Write a factory function that accepts a baseUrl as parameter, and returns an object having get and post functions, which get and post an endpoint respectively.
Try to understand it's similarities to a class-based version, which accepts a baseUrl in the constructor and has two get and post methods. Most of the times, you can swap a class for a factory function, and vice versa.
Factory function is a very powerful tool for a Javascript developer. So, try to play with it for a while, in addition to finishing merely this task.

What to google

  • Javascript factory functions (note that it has nothing to do with factory method design pattern)
  • Javascript closures (just give it a look, it's an advanced - though fundamental - JS feature)

Suggested resources

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions