Skip to content

Instantly share code, notes, and snippets.

@redbluish
Created April 2, 2014 03:01
Show Gist options
  • Save redbluish/9927280 to your computer and use it in GitHub Desktop.
Save redbluish/9927280 to your computer and use it in GitHub Desktop.
jQuery.map的坑
_.map(['foo', 'bar'], function (item, index) {
return [index, item];
});
['foo', 'bar'].map(function (item, index) {
return [index, item];
});
$(['foo', 'bar']).map(function (index, item) {
return [index, item];
});
$.map(['foo', 'bar'], function (item, index) {
return [index, item];
});
$.map([1, 2, [3, 4], [5, [6, [7, 8]]]], function recurs(n) {
return n;
});
$.map([1, 2, [3, 4], [5, [6, [7, 8]]]], function recurs(n) {
return $.isArray(n) ? $.map(n, recurs) : n;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment