To convert the array contents.data
to Set, do this:
const setData = new Set(contents.data);
That will remove all the duplicate items.
Then to convert it back, do this:
const uniqueArray = Array.from(setData);
The above will only work if the original array (contents.data
) consisted of primitive values. If it was an array of objects then this will not work as-is and will require some changes.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…