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

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

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 Denunciar

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 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