Return to Snippet

Revision: 26439
at April 28, 2010 11:15 by chrisaiv


Initial Code
function removeDuplicate(arr:Array) : void{
    var i:int;
    var j: int;
    for (i = 0; i < arr.length - 1; i++){
        for (j = i + 1; j < arr.length; j++){
            if (arr[i] === arr[j]){
                arr.splice(j, 1);
            }
        }
    }
}

var arr:Array = new Array("a", "b", "a", "c", "d", "b");
removeDuplicate(arr);

Initial URL
http://thinkdiff.net/flash-action-script-30/in-actionscript-3-how-to-remove-duplicates-from-array/

Initial Description
I found this awesome function that allows you to easily remove duplicate values.

Initial Title
AS3: Remove Duplicates in an Array

Initial Tags
array

Initial Language
ActionScript 3