Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

398
Vistas
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 Respuestas
Responde la pregunta

0

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

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda