Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

107
Views
Should input parameters be an object or just multiple params

When I design an API that includes 5 input parameters, should the parameters be passed in in the form of objects, or just multiple params?

There is no relationship between parameters.

const apiMethod = (parma1, parma2, parma3, parma4, parma5) => {……}

or

let param = {parma1, parma2, parma3, parma4, parma5}
const apiMethod = (param) => {
  ...param
  // ……
}

which one is best?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Always choose a single object or map over multiple params.

  • you can add additional properties without breaking api
  • you can put the params in any order
  • the property names make the code self documenting
  • you can define the object as a typescript type
  • you dont have to worry about order to accomodate optional params
  • you can extend or alter the type for other method calls.
  • you can destructure the params to clean up code if needed.
  • probably many more advantages, with not many disadvantages...
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!