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

230
Views
How to correctly use objects instead of multiple parameters?

How to correctly use objects instead of multiple parameters in my case?

class Test{ 
async createUser(
    url: string,
    name: string,
    email: string,
    phone: string,
    street: string,
...
  ) {
    await Page.setUrl(url);
    await Page.setEmail(email);

 ...
   
  }
}
about 4 years ago · Santiago Gelvez
2 answers
Answer question

0

you can use an interface


interface User {
  url: string;
  name: string;
  email: string;
  phone: string;
  street: string;
}

class Test{ 
async createUser(user: User) {
    await Page.setUrl(user.url);
    await Page.setEmail(user.email);

 ...
   
  }
}
about 4 years ago · Santiago Gelvez Report

0

use the concept of spread operators. Know more about it here:

create an object variable like this:

result = { 
    url: string,
    name: string,
    email: string,
    phone: string,
    street: string,
}

and then pass it as a parameter like this

 async createUser (...result){
    //get variable you wan to use
    const {url, name, email} = result;
    //your code here
   }
about 4 years ago · Santiago Gelvez 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!