<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> <style> div{padding:20px;} </style> </head> <body style="overflow:hidden;"> <script> var each = function(arr, fn){ for(var index in arr){ fn.apply(null,[index,arr[index]]); // fn.call(null,index,arr[index]); } } var myArr = [1, 5, 6, 8]; each(myArr, function(index, item){ item++; console.log(item) }) </script> </body> </html>