html JS.Basics.Arrays.IteratingArraysForLoop.js

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html JS.Basics.Arrays.IteratingArraysForLoop.js相关的知识,希望对你有一定的参考价值。

var persons = [
  {name:'Michel', age:51},
  {name:'Henri', age:20},
  {name:'Francois', age:29},
  {name:'John', age:69}
];

for(var i = 0; i < persons.length; i+=2) {
  var p = persons[i]; // current element
  
  document.body.innerHTML += p.name + "<br>"; 
}
JS.Basics.Arrays.IteratingArraysForLoop.js
------------------------------------------


A [Pen](https://codepen.io/Onlyforbopi/pen/VGOPeo) by [Pan Doul](https://codepen.io/Onlyforbopi) on [CodePen](https://codepen.io).

[License](https://codepen.io/Onlyforbopi/pen/VGOPeo/license).
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Draw a monster in a canvas</title>
</head>
<body>
  <p>
    <b>These nameshave been generated dynamically 
      by iterating 2 elements by 2 on an array using a <code>for</code> loop.</b>
  </p>
</body>
</html>  

以上是关于html JS.Basics.Arrays.IteratingArraysForLoop.js的主要内容,如果未能解决你的问题,请参考以下文章

html Html模板/ Html Boilerplate |标签HTML

html里怎么引用一个html的头部

html5与传统html区别

html4和html5的区别

HTML元素

head标签怎么给多个html引用