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

397
Views
How can I explicitly assign a receiving variable to be an array

ok, so, I was doing this before and its working:

let array = [];
if (blablabla) array = ["foo","bar"];
else array = ["this", "that"];
FunctionImUsing(array)

And then the method will receive the array correctly and no problem.

this.FunctionImUsing = function (array) {
//works with the array inside the function. No problem
}

However, I wanted to do this:

if (blablabla) FunctionImUsing(["foo","bar"]);
else FunctionImUsing(["this","that"]);

But it doesnt work. the method receives only the first element and not the full array. How can I force the receiving variable to be an array?

I tried this

this.FunctionImUsing = function (array[]) {

but Javascript wont let me do that (Unexpected Token). I wanted to force the receiving variable of a function to be an array.

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

0

found the issue, it was missing a [ one of the statesments. Lol

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!