js array cycle is repeated problems

There is the need to back a demand to pass my data appears in the pop-up box to select, as

 

 Background returned data format

 

 But I need only the tip of the contents of the box, the other not, at first I wanted to give me back the two data directly back on the line, and then I give it two data directly assigned as follows:

 

 But do not want to change the background, then I can only own up to reassemble a json

Define an empty array, again an empty object, each cycle, two values ​​need to put an object inside, and then push to an array of objects inside, so it is not perfect yet? However, encountered a problem, which is an array of data that the new definition is repeated, how it happened

Here is my test code

 

 The reason is that if I put the empty object written in that place, then, this array will always be an object, then each cycle will be covered by its value, how to solve it, that is, each time a new cycle of objects, so is more than one object, complementary interference, there would be no repeat of the problem

 

 

 

 

Guess you like

Origin www.cnblogs.com/lyt0207/p/12307113.html