Javascript - Reduce and Array
<p>I am trying to find get unique records by their ID including the name with the code most below and if I replace the <code>if</code> statement with:</p>

<pre><code>if (p.indexOf(c.ID) &lt; 0) p.push(c.ID);
</code></pre>

<p>it will create an array with unique IDs, but I want my final array to also have person's name so I modified the if statement, but then p[1] is not initialized for the first time and the reduce function doesn't run as expected. How do I correctly change the code below to work for what I want?</p>

<pre><code>var arrayUnique = function(a) {
    return a.reduce(function(p, c) {
        if (p[1].indexOf(c.ID) &lt; 0) p.push([c.person, c.ID]);
        return p;
    }, []);
};
</code></pre>