Removing duplicates from an array quickly
You can use the indexOf function to check if a value exists in an array. This would simplify your code greatly:

Array.prototype.unique = function() {
    var a = [];
    for ( i = 0; i &lt; this.length; i++ ) {
        var current = this[i];
        if (a.indexOf(current) &lt; 0) a.push(current);
    }

    this.length = 0;
    for ( i = 0; i &lt; a.length; i++ ) {
        this.push( a[i] );
    }

    return this;
}


At the end you are replacing the array's content. It would be better to not mutate the original array, but to return the new array instead with unique elements:

Array.prototype.unique = function() {
    var a = [];
    for ( i = 0; i &lt; this.length; i++ ) {
        var current = this[i];
        if (a.indexOf(current) &lt; 0) a.push(current);
    }
    return a;
}


The name a is a very poor choice. unique would have been better.

You should declare the loop variable i using let, to limit its scope to the current block, so the code becomes:

Array.prototype.unique = function() {
    var unique = [];
    for (let i = 0; i &lt; this.length; i++) {
        let current = this[i];
        if (unique.indexOf(current) &lt; 0) unique.push(current);
    }
    return unique;
}


Finally, there is a much more elegant solution to this problem, using the reduce function:

Array.prototype.unique = function() {
    return this.reduce(function(accum, current) {
        if (accum.indexOf(current) &lt; 0) {
            accum.push(current);
        }
        return accum;
    }, []);
}


UPDATE (to answer your follow-up question)

If you want the function to take a parameter to decide whether it should modify the original array, you could try something like this:

Array.prototype.unique = function(mutate) {
    var unique = this.reduce(function(accum, current) {
        if (accum.indexOf(current) &lt; 0) {
            accum.push(current);
        }
        return accum;
    }, []);
    if (mutate) {
        this.length = 0;
        for (let i = 0; i &lt; unique.length; ++i) {
            this.push(unique[i]);
        }
        return this;
    }
    return unique;
}