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

233
Visualizações
Insert an array into another array

I am handling a Javascript function to have a behaviour below:

1/ When the checkbox button is checked, an array of setting strings is inserted into another array

var RB_array_1=[];
var mycheckboxButton1 = document.getElementById('mycheckboxButton1');
if (mycheckboxButton.checked===true) {
  RB_array_1=["setting A_1","setting B_1"]
}

2/ It will insert into another array while it remain the array inside previously:

const final_array = 
  [ RB_array_1
  , RB_array_2
  , ...
  , RB_array_x
  ] 

and it should remain array inside the array:

const final_array = 
  [ [ 'setting A_1', 'setting B_1'] 
  , [ 'setting A_2', 'setting B_2'] 
  , ...
  , [ 'setting A_x', 'setting B_x'] 
  ]      

Is there any way to insert an array into another array ?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Seems like you're looking for the push method. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push

const arr1 = [1,2,3];
const arr2 = [4,5,6];
const arrs = [arr1];

arrs.push(arr2);

console.log(arrs);

about 4 years ago · Juan Pablo Isaza Relatório

0

RB_array_1.push(["setting A_1","setting B_1"])

just make sure whatever you push inside your final array element also has to be an ARRAY. Should work fine according to me.

Refer this for an example

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