Opened 11 years ago
Closed 11 years ago
#11541 closed bug (invalid)
.unique() method, Can not remove duplicates in Google Chrome
Reported by: | deg84 | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | None |
Component: | misc | Version: | 1.7.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Confirm the phenomenon in Gogole Chrome 18.0.1025.142 beta
Example 1:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <body> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript"> var a = [1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2]; $.unique(a); console.log(a); </script> </body> </html>
Result:
[1,2,1]
But I hope Result:
[1,2]
or
[2,1]
Example2:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <body> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript"> var a = ['2012-02-01','2012-02-01','2012-02-01','2012-02-01','2012-02-01','2012-02-01','2012-02-01','2012-02-01','2012-02-01','2012-02-01','2012-02-01','2012-02-01','2012-02-02','2012-02-02','2012-02-02','2012-02-02','2012-02-02','2012-02-02','2012-02-02','2012-02-02','2012-02-02',]; $.unique(a); console.log(a); </script> </body> </html>
Result:
["2012-02-01", "2012-02-02", "2012-02-01"]
But I hope Result:
["2012-02-01", "2012-02-01"]
or
["2012-02-02", "2012-02-01"]
Change History (1)
comment:1 Changed 11 years ago by
Component: | unfiled → misc |
---|---|
Priority: | undecided → low |
Resolution: | → invalid |
Status: | new → closed |
Note: See
TracTickets for help on using
tickets.
From the docs:
The method only accepts an array of DOM elements, not strings or numbers.