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

6

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.

| improve this answer | |
  • 1
    Awesome thank you @sfdxfox , I will definitely go through MDN thanks for your guidance. – vkm Jul 6 at 15:09
  • 1
    also another way [...listA,...listB]. – rahul gawale Jul 6 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.