1,回调函数的参数顺序相反,each:i,elem,map:elem,i

2,返回值不同,map返回一个新的数组,each返回原始数组

回调的返回值,each只能返回 true 和 false,map返回的是新数组的元素

3,map 的回调函数里 ,没有 this,each中的this代表当前迭代对象

4,chrome 中 ,javascript是自带map方法的

var aaa = [11, 22, 33];
aaa.map(function (a, b) {
console.log('a=' + a + ',b=' + b);
return a * b;
});

结果:

a=11,b=0
a=22,b=1
a=33,b=2
[0, 22, 66]
所以,chrome中的map与$.map是一致的,但是chrome的map看不到内部的实现
 
5,$("xxx").map和$.map是一样的,$("").map:
function ( callback ) {
return this.pushStack( jQuery.map(this, function( elem, i ) {
return callback.call( elem, i, elem );
}));
}

each 也是同样情况:$("").each:

function ( callback, args ) {
return jQuery.each( this, callback, args );
}

总结:

在我看来,jquery的map方法,可以理解为 sql语句中的 where,或者linq中的where

而each仅仅是一个迭代器,相当于foreach,毕竟javascript是没有foreach的,这也许是补充吧

http://msdn.microsoft.com/zh-cn/express/ff679976(v=vs.90)

http://stackoverflow.com/questions/749084/jquery-map-vs-each

Jquery each和map 的区别的更多相关文章

  1. jQuery介绍 DOM对象和jQuery对象的转换与区别

    jQuery介绍 DOM对象和jQuery对象的转换与区别 jQuery介绍      jQuery: http://jquery.com/      write less, do more.   j ...

  2. Java-list,set,map的区别

    jdk中api的定义 Collection ├----List │ ├----LinkedList │ ├----ArrayList │ └----Vector │ └----Stack └----S ...

  3. list和map的区别

    list和map的区别 list-->list是对象集合,允许对象重复 map-->map是键值对的集合,不允许key重复

  4. c++ list, vector, map, set 区别与用法比较

    http://blog.csdn.net/alex_xhl/article/details/37692297 List封装了链表,Vector封装了数组, list和vector得最主要的区别在于ve ...

  5. jquery生产和开发的区别

    今天说一下jquery生产和开发的区别,在我们下载jquery的时候,会有两个下载链接,一个是jquery.min.js .迷你版 (生产),另一个是 jquery.js .开发版 .不知道的人可能就 ...

  6. JQuery this和$(this)的区别及获取$(this)子元素对象的方法

    1.JQuery this和$(this)的区别 相信很多刚接触JQuery的人,很多都会对$(this)和this的区别模糊不清,那么这两者有什么区别呢? 首先来看看JQuery中的  $()  这 ...

  7. hash_map和map的区别

    hash_map和map的区别 分类: STL2008-10-15 21:24 5444人阅读 评论(0) 收藏 举报 class数据结构编译器存储平台tree 这里列几个常见问题,应该对你理解和使用 ...

  8. Map的clear与new Map的区别

    对于clear与new Map的区别.我们首先来看一个例子,本例子是我在实际开发中遇到的,需求就是讲map放入到list中,说白了就是list转map,有两种实现方式,分别是: // 方案一 Map& ...

  9. Java集合:List、Set和Map的区别,ArrayList和LinkedList有何区别..........

    一.数组和集合的区别: 数组是大小固定的,并且同一个数组只能存放类型一样的数据(基本类型/引用类型): 集合可以存储和操作数目不固定的一组数据. 所有的JAVA集合都位于 java.util包中! J ...

随机推荐

  1. LeetCode()Substring with Concatenation of All Words 为什么我的超时呢?找不到原因了!!!

    超时代码 class Solution { public: vector<int> findSubstring(string s, vector<string>& wo ...

  2. hdu1811 并查集+拓扑序

    题意:现在有一个排名系统,有一系列信息,分别是 > < = 的比较,而如果最终相等,就会将这些相等的按照序号从小到大排,问给出的信息是否可以确定完整的排序. 由于如果很多点相等,他们肯定能 ...

  3. ThinkPHP使用SQL函数进行查询

    //SQL函数查询 $products=$pro->where(array("FIND_IN_SET('".$type."',type)",'num'=& ...

  4. Python 判断一个字符串是否在列表中任何一个字符串中出现过

    strlist = ['a1', 'a2', 'b1'] if any("a" in s for s in strlist):

  5. java多线程:并发包中ReentrantLock锁的公平锁原理

    一:锁的原理结构 (1)锁对象内部维护了一个同步管理器的对象AbstractQueuedSynchronizer,AbstractOwnableSynchronizer (2)该对象其实是一个抽象类, ...

  6. nginx无法启动: libpcre.so.1/libpcre.so.0: cannot open shared object file解决办法

    NGINX启动时提示错误: /usr/local/nginx/sbin/nginx -t/usr/local/nginx/sbin/nginx: error while loading shared ...

  7. 使用支持向量机训练mnist数据

    # encoding: utf-8 import numpy as np import matplotlib.pyplot as plt import cPickle import gzip clas ...

  8. linux工具类之硬盘检测

    软raidmount /dev/md0 /opt                [root@localhost root]# cp /usr/share/doc/raidtools-1.00.3/ra ...

  9. Q3: Linked List Cycle II

    问题描述 Given a linked list, return the node where the cycle begins. If there is no cycle, return null. ...

  10. HOCON 了解

    Spec This is an informal spec, but hopefully it's clear. Goals / Background The primary goal is: kee ...