Side navigation
#11541 closed bug (invalid)
Opened April 01, 2012 06:18AM UTC
Closed April 01, 2012 01:04PM UTC
.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"]
Attachments (0)
Change History (1)
Changed April 01, 2012 01:04PM UTC by comment:1
| component: | unfiled → misc | 
|---|---|
| priority: | undecided → low | 
| resolution: | → invalid | 
| status: | new → closed | 
From the docs:
The method only accepts an array of DOM elements, not strings or numbers.