方艺蒙,白猫图库,万庆良与叶家关系
forEach() : 对数组进行遍历循环,对数组中的每一项运行给定函数。
格式: arr.forEach(function(value,index){})
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <body> <script> var arr = [1, 3, 5, 7, 9, 11,'哈哈']; arr.forEach(function (value, index) { console.log(index + ':' + value); }) </script> </body> </html>
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Object.keys() 和 Object.getOwnPropertyNames() 的区别详解
JavaScript使用prototype属性实现继承操作示例
JavaScript直接调用函数与call调用的区别实例分析
JavaScript设计模式--简单工厂模式实例分析【XHR工厂案例】
网友评论