title: How to make simple php's foreach equivalent in Javascript?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3010840/loop-through-array-in-javascript">Loop through array in JavaScript</a>  </p>
  </blockquote>
  
  
  
  <p>I want to make the equivalent of php's foreach in javascript. Because I don't really know the Javascript language, I'd like someone to rewrite this PHP code into the Javascript piece:</p>
  
  <pre><code>$my_array = array(2 =&gt; 'Mike', 4 =&gt; 'Peter', 7 =&gt; 'Sam', 10 =&gt; 'Michael');
  
  foreach($my_array as $id =&gt; $name)
  {
       echo $id . ' = ' . $name;
  }
  </code></pre>
  
  <p>Is that even possible to do in the Javascript language?</p>