1

I'm looking for a way to copy wrapper list of content values to a single list

Example:

LIST<wrapper> dataAandB= [LIST A,LIST B] => List A =[Object X :{Id,Name ... }] and List B =[Object Y :{Id,Name, ...}]

let xObjlist = [];

xObjlist=List A;

Is it possible to copy without using data.forEach() ?

1 Answer 1

7

Yes. You can use concat:

var output = listA.concat(listB);

Or you can flatten it:

var output = [listA,listB].flat();

Arrays in JS are very robust. You should take time to study their many features on MDN.

2
  • 1
    Awesome thank you @sfdxfox , I will definitely go through MDN thanks for your guidance.
    – vkm
    Jul 6, 2020 at 15:09
  • 2
    also another way [...listA,...listB]. Jul 6, 2020 at 15:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .