Move object from one array to another

后端 未结 3 1098
暗喜
暗喜 2021-01-13 23:07

i have one object that one of the properties is an array of objects, the idea is to move objects from that array to no new one if one condition is true.

publ         


        
3条回答
  •  渐次进展
    2021-01-13 23:56

    You are removing elements as you loop through your array - this is never a good idea. A better way to solve this issue is to add them to this.comments first and when the foreach is finalized, start looping over this.comments and remove those that are in this array out of the messages.

提交回复
热议问题