自己實作js array prototype unique function

自己寫一個js array prototype unique function

Array.prototype.unique = function()
{
    var n = []; 
    for(var i = 0; i < this.length; i++) 
    {
        if (n.indexOf(this[i]) == -1) n.push(this[i]);
    }
    return n;
}

var arr = ["a","b","c","b","d","a","c","c"];

console.log(arr.unique());
//輸出["a", "b", "c", "d"]