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


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() ?


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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.