How to pass extended parameter to a function? : <p>I'm trying to pass a parameter to a function so that I can call my array object elements multiple times (since I have them quite a lot, returned from the sql query).</p>

<pre><code>removeDuplicates(arr, x){
    var tmp = [];
    var tmp2=[];
    for(let i = 0; i &lt; 50; i++){
        if(tmp.indexOf(arr[i].id) == -1){
        tmp.push(arr[i].id); //always id
        tmp2.push(arr[i].x);  //for example arr[i].name
        }
    }
    return tmp2;
}
</code></pre>

<p>If I do it like that and call the method like this:</p>

<pre><code> removeDuplicates(arraytag2, arraytag2.name); 
</code></pre>

<p>it doesn't work.</p>
