2021年3月25日星期四

Change indexes of an array to a JavaScript string

Hello js sabers I am trying to see if it is possible to create or modify an array:

    [          {title: "METER_STATE", elements: [              {combo: "a", id: 1},              {combo: "b", id: 2},              {combo: "c", id: 3},          ]},          {title: "REGULATOR_STATE", elements: [              {combo: "aa", id: 1},              {combo: "bb", id: 2},              {combo: "cc", id: 3},          ]},          {title: "ACTIVITY_TYPE", elements: [              {combo: "aaa", id: 1},              {combo: "bbb", id: 2},              {combo: "cccc", id: 3},          ]}      ]  

What I am trying to do is modify that instead of having numerical indexes (0,1,2 according to the example) they are for example (STATUS_MEDIDOR, STATUS_REGULATOR and TYPE_ACTIVITY) I do not know if it is possible that is why I go with you, I have investigated in google but i don't see anything clear, searched like "replace array index to any javascript phrase" but didn't find something to really help me. The reason for this is that I am from an xml view reading each item in the following way "fixname/0/items" so I had the doubt that instead of using the indexes I could use something else

Does anyone know about it?

Beforehand thank you very much

https://stackoverflow.com/questions/66805646/change-indexes-of-an-array-to-a-javascript-string March 26, 2021 at 02:32AM

没有评论:

发表评论