码迷,mamicode.com
首页 > 编程语言 > 详细

javascript与jQuery的each,map回调函数参数顺序问题

时间:2016-10-29 02:04:09      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:ons   com   http   alt   border   tar   image   span   href   

<script>
var arr = [2,3,6,7,9];
//javascript中的forEach 和 map方法
arr.forEach(function(value,index){//(值,索引)
console.log(value);
});
arr.map(function(value,index){//(值,索引)
console.log(value);
});

//jQuery的 each map方法
$(arr).each(function(index,value){//(索引,值)
console.log(index);
});
$.each(arr,function(index,value){//(索引,值)
console.log(index);
});

$.map(arr,function(value,index){//(值,索引)
console.log(index);
});
$.map(arr,function(value,index){//(值,索引)
console.log(index);
});

//总结:只有jQuery的each方法,回调处理函数的中的参数是(索引,值),其它的都是(值,索引);


</script>
技术分享




javascript与jQuery的each,map回调函数参数顺序问题

标签:ons   com   http   alt   border   tar   image   span   href   

原文地址:http://www.cnblogs.com/itlyh/p/6009721.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!