jQuery中map方法

jQuery的map方法可以遍历数组,也可以遍历伪数组

$(function(){
            var arr=[1,2,34,]
            var fakeArray = {
            length: 3,
            "0": "first",
            "1": "second",
            "2": "third"
            };
 
            $.map(arr,function(value,index){    //arr要遍历的数组,value遍历的值,index遍历的索引
                console.log(index,value)
                }
            )
            $.map(fakeArray,function(value,index){
                console.log(index,value)
                }
            )
        })

 

posted @ 2018-10-29 22:42  大C文  阅读(740)  评论(0编辑  收藏  举报