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

Posted itly

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript与jQuery的each,map回调函数参数顺序问题相关的知识,希望对你有一定的参考价值。

<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);
});

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


</script>




以上是关于javascript与jQuery的each,map回调函数参数顺序问题的主要内容,如果未能解决你的问题,请参考以下文章