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

199
Views
Which is the way to check an argument is an array and if not turn it into it in Javascript?

There is a function that receives one argument from a query. If the query is only one item the input will be a string like for example "1". Otherwise if the query has two the argument will be an array like ["1", "2"].

I eventually need to work with an array to use it on a for each and work with the data. So i found this solution but i don't think is the best way to perform this.

//orderInput can be an string "1" or an array of strings ["1","2"]
const parseOrder = (orderInput) => {

    const array = [].concat(orderInput);
    array.forEach(odr => {
        // Here it does something
    });


    return order;
}

about 4 years ago · Juan Pablo Isaza
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!