Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

404
Visualizações
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 Respostas
Responde à pergunta

0

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

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda