Merge the values of an Array inside another Array

Asked

Viewed 217 times

0

I have several Arrays throughout the program to check identifiers Soon in a function I check a include to know if a particular identifier is inside an object

the object has the following format

  {
    suport: [ id[0], id[1], id[2], 'informations' ],
    alt: 'Whatsapp',
    description: 'Troque mensagens com os seus amigos.',
    icon: require('@/assets/images/icons/icon-whatsapp.svg')
  }

right in the key suport I check if where I called the include, will return me one of the values of this Array, works perfectly in this format, since I put the Ids separately, then it works, the problem is, I have only 3 identifiers in this example, in which case are all the Ids that the program has, being only 3 ids, it is simple, the problem is, when I get to a large number of Ids, it will become very large, if I put suport: [ id, 'informations' ] it creates a sub array within this array, so my include does not return as it only searches the main array

how I would join the array id inside the array support?

id = [ 'a', 'b', 'c' ]
suport: [ id, 'informations' ]

console.log(suport) // [ 'a', 'b', 'c', 'informations' ]

exsite how to do this without a function? since I cannot create a new function for this case, I would need to run there inside the array like for example toString that works but only creates 1 index in the array with the 3 ids separated by comma, which does not serve in the case, unless of toString to create 3 index

1 answer

0


  • our, very good, really simple, did not pass the Concat in my head, thank you very much

Browser other questions tagged

You are not signed in. Login or sign up in order to post.