node.js - How to get loop variables in nodejs using for of to traverse Map
phpcn_u15822017-06-14 10:52:45
0
2
1560
My problem is to prevent duplicate data from being inserted when adding data to the array, so I thought of map, but I don’t know how to get the index after traversing the Map structure. If I don't use map, is there any other concise way?
`for(value of map){
}`
1. The simplest
Every time you insert it, use the
unique key
to check whether it already exists2. Use Object method when storing
If you want to sort things in order when calling, use
index
to sort and then output.3. Create an index table while saving Array