function unique( arr ) {
	var len;
	var out;
	var val;
	var i;
	var j;

	// Copy the array to avoid mutation:
	out = Array.prototype.slice.call( arr );
	len = out.length;

	// Sort array in ascending order:
	out.sort( ascending );

	// Loop through the array, only incrementing a pointer when successive values are different. When a succeeding value is different, move the pointer and set the next value. In the trivial case where all array elements are unique, we incur a slight penalty in resetting the element value for each unique value. In other cases, we simply move a unique value to a new position in the array. The end result is a sorted array with unique values.
	for ( i = 1, j = 0; i < len; i++ ) {
		val = out[ i ];
		if ( out[ j ] !== val ) {
			j += 1;
			out[ j ] = val;
		}
	}
	// Truncate the array:
	out.length = j+1;
	return out;
}
Returns the unique elements in an array.

@private
@param {Array} arr - input array
@returns {Array} array of unique elements