javascript 写一个 map方法
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <script> Array.prototype.map = function(fn){ for (i=0;i<this.length;i++){ v = this[i]; k = i; fn(v,k,this) } } // console.log(Array.prototype.map); var arr = [111,222,333]; arr.map(function(v,k){ console.log(v,k) }) </script> </body> </html>