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

227
Views
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 answers
Answer question

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 Report

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