Array.uniq does not work in Prototype

Updated . Posted . Visible to the public.

For arrays of objects, uniq does not work as expected, since it uses strict equality. So

[[1], [1]].uniq() == [[1], [1]]

In some cases, this might be a workaround:

[[1], [1]].invoke("toJSON").uniq().invoke("evalJSON")   
// == [[1]]
Tobias Kraze
Last edit
License
Source code in this card is licensed under the MIT License.
Posted by Tobias Kraze to makandra dev (2010-08-25 13:22)