Closed Bug 489780 Opened 17 years ago Closed 14 years ago

New JavaScript Method: create a new method named removeDuplicates() to remove duplicate entries from an array

Categories

(Core :: JavaScript Engine, enhancement)

x86_64
Linux
enhancement
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: linuxed7, Unassigned)

Details

User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.8) Gecko/2009032712 Ubuntu/8.10 (intrepid) Firefox/3.0.8 Build Identifier: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.8) Gecko/2009032712 Ubuntu/8.10 (intrepid) Firefox/3.0.8 Lets say that you have an array of integers or strings. The array may contain numerous duplicate strings or integers. Currently to remove those duplicates you would have to code it something like the following. var test = [1,2,3,1,5,2,1]; test.sort(); for (var i=0; i<test.length; ++i) { while (test[i] == test[i+1]) { test.splice(i,1); } } alert(test); It would be great if you could simplify this procedure by creating a built-in javascript method to provide this feature. var test = [1,2,3,1,5,2,1]; test = removeDuplicates(test); Reproducible: Always
Revised example: var test = [1,2,3,1,5,2,1]; test.removeDuplicates();
We don't really do this kind of work, instead it gets done in ECMA (http://www.ecmascript.org/), and we implement their standards.
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → INVALID
We have a lot of old JavaScript feature request, should we really close them?
I only closed this because it came up in a search and I read it. It seems spending time on closing them probably isn't worth it, but if we've already opened and read the bug, then we may close it too.
You need to log in before you can comment on or make changes to this bug.