首页 > 代码库 > javascript中的for……in循环

javascript中的for……in循环

  <script type="text/javascript">
   var theBeatles=new Array("John","Paul","Gearge","Ringo");
   for(var loopCounter=0;loopCounter<theBeatles.length;loopCounter++){
       document.write(theBeatles[loopCounter]+"<br>");
   }
   var indexKey;
   for(indexKey in theBeatles){
       document.write("indexKey is "+indexKey+"<br>");
       document.write("item value is "+theBeatles[indexKey]+"<br><br>");
   }
   </script>

javascript中的for……in循环