using unique() for array
using unique() for array

in Bug reports
Hi
when I used this code:
table.column(1).data().unique();
The returned value was not an array that contains unique values. In this column I have an array for each cell.
[["1", "4"], ["1", "4"], ["1", "4"], ["1", "4"], ["1", "4"], ["1", "4"], ["1", "4"], ["1", "4"], ["1", "4"], ["1", "4"], ["1", "4"], ["1", "4"], ["1", "4"], ["1", "4"], ["1", "4"], ["1", "4"], ["1", "4"], ["1", "4"], ["1", "4"], ["1", "4"], ["2", "4"], ["2", "4"], ["2", "4"], ["2", "4"], ["2", "4"], ["2", "4"], ["2", "4"], ["4"], ["4"], ["4"], ["4"], ["4"], ["4"], ["2", "4"], ["2", "4"], ["2", "4"], ["2", "4"], ["4"], ["4"], ["4"], ["4"], ["4"], ["4"], ["4"], ["4"], ["4"], ["4"], ["4", "8"], ["1", "2", "4"], ["2", "4"], ["2", "4"], ["4", "16"], ["4", "16"], ["2", "4"], ["1", "4"], ["4", "16"], ["2", "4"], ["2", "4"], ["2", "4"], ["2", "4"], ["2", "4"], ["2", "4"]]
what should I do?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
The
unique()
method will compare the objects at the top level - so in Javascript["1", "4"] !== ["1", "4"]
hence why unique doesn't work for your use case.If you need to check if the inner arrays are unique, you would need to perform the loop check yourself.
Allan