Please, help me to understand, how to use $.unique()
function.
From the docs:
Sorts an array of DOM elements, in place, with the duplicates removed.
I'm trying this code:
<h1 class="foo">Headline</h1>
<h1 class="foo">Headline</h1>
<h1 class="foo">Headline</h1>
alert( $.unique($('.foo')).length );
It returns 3, but I supposed 1. What am I missing? And it would be great to see some practice example of using this function. Thanks.
P.S.
I've also tried to sort a few numbers, but got a very curious result. The following code returns different values in different browsers!
$.unique([ 1, 2, 2, 3, 3, 1 ])
- Safari - 1, 2, 3, 1
- Opera - 2, 1, 3
- FF - 3, 2, 1, 3
- Chrome - 3, 2, 1
- IE - 2, 1, 3