ArrayUnique
Returns a new array with duplicate items removed.
values = [ 1, 1, 2, 3, 3 ];
values.unique(); // [ 1, 2, 3 ]
Method Signature
ArrayUnique(array=[array], caseSensitive=[boolean])Arguments
Argument
Type
Required
Description
Default
array
array
true
The array to remove duplicate entries from
caseSensitive
boolean
false
Whether string element comparisons are case-sensitive. Defaults to false.
false
Examples
Remove duplicate values from an array
items = [ "apple", "banana", "apple", "cherry", "banana" ];
result = items.unique();
writeOutput( result.len() );
Result: 3
Case-insensitive deduplication (default)
Result: 2
Using the global function form
Result: [1, 2, 3]
Related
Last updated
Was this helpful?
