There’s one way to optimise that. Iterate over both loops backwards, e.g.
function removeDuplicate(arr:Array) : void{
var i:int;
var j: int;
for (i = arr.length - 2; i >= 0 ; i--){
for (j = arr.length - 1; j > i; j--){
if (arr[i] === arr[j]){
arr.splice(j, 1);
}
}
}
}
This is better as it’s not repeatedly retrieving the length of the Array, something it only needs once, or once through. It’s also safer to go through an Array in reverse order; one problem with your current code is that when you remove an element it moves every element down and you skip over one when you move to the next. You can fix this by decreasing j when you splice, but it’s simpler and more efficient to loop through them with decreasing indices.
But however you do it two loops is expensive. Sorting first would mean you could use just one loop, an order of magnitude more efficient.