How to get index value of same array value in javascript
<p>Now i have an array <code>var a = [4,7,4]</code> in this array value 4 is same values and how can i get the index of same value.</p>

<p>I got some code in StackOverflow but its checking only num 2 value, i need to check every element and <strong>return index value</strong>.</p>

<p><strong><em>JS:</em></strong></p>

<pre><code>var dataset = [2,2,4,2,6,4,7,8];
var results = [];
for ( i=0; i &lt; dataset.length; i++ ){
    if ( dataset[i] == 2 ){
        results.push( i );
    }
}

return results;
</code></pre>

<p><a href="http://jsfiddle.net/friendz/42y08384/15/" rel="nofollow">JSFIDDLE</a></p>

<p><a href="http://jsfiddle.net/friendz/42y08384/15/" rel="nofollow">http://jsfiddle.net/friendz/42y08384/15/</a></p>