Posted By

halk on 10/15/12


Tagged

foreach


Versions (?)

Javascript Equivalent Of PHP foreach


 / Published in: JavaScript
 

This is the equivalent of doing php's foreach loop in javascript.

  1. //In PHP
  2.  
  3. foreach($data as $key => $value){
  4. //write code here
  5. }
  6.  
  7. //In Javascript the same construct looks like this
  8. for(key in obj){
  9. var value = obj[key];
  10. //write code here
  11. }

Report this snippet  

You need to login to post a comment.