|
Array.unique Method
Makes a copy of an Array with all duplicate values removed.
object.unique (sorted)
Arguments
- object
- Required. Always the name of an Array object.
- sorted
- Optional. Boolean value indicating whether the original array is sorted.
A sorted array will process faster.
Return Value
The Array.unique method returns an array.
Remarks
The following example illustrates the use of the Array.unique method.
// Let's create some arrays, perform some actions, and compare the arrays.
var a = new Array("a", "c", "b", "d", "b", "j", "d", "g", "e");
Console.Writeln(a.toString()); // returns "a,c,b,d,b,j,d,g,c,e"
var b = a.clone(); // make a copy of the original array
Console.Writeln(b.toString()); // returns "a,c,b,d,b,j,d,g,c,e"
var z = b.unique(false); // remove the duplicates
Console.Writeln(z.toString()); // returns "a,c,b,d,j,g,e"
var c = a.clone().sort(); // make a sorted copy of the original array
Console.Writeln(c.toString()); // returns "a,b,b,c,c,d,d,e,g,j"
var y = c.unique(true); // remove the duplicates
Console.Writeln(y.toString()); // returns "a,b,c,d,e,g,j"
Requirements
Array.clone(), Array.indicesof(), Array.remove()
|