var arr = new Array(); arr[0] = 'Departmental News' arr[1] = 'Departmental News' arr[2] = 'Another Cat' arr[3] = 'Another Cat' arr[4] = 'Departmental News'
alert(arr)
alert($.unique(arr))
In IE I get duplicates. In any other browser only the unique ones
Any Ideas?
This is the intended behavior. Though $.unique() does work for strings in most cases, it's not guaranteed to, the documentation specifically states it's only for DOM elements.
From the docs:
Sorts an array of DOM elements, in place, with the duplicates removed. Note that this only works on arrays of DOM elements, not strings or numbers.
The way it works internally works for DOM elements cross-browser, but that same implementation doesn't work consistently for other things, namely strings/numbers which is why they're singled out so specifically in the documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With