4

Why would the following jquery code sometimes throw the error "concat is not a function":

var myArray = $('div.foo')
    .filter(function() { return $(this).is('.something'); })
    .map(function() { 
        return [['a', 'b', $(this).val()]];
    });

return myArray.concat(anotherArray);
4

2 回答 2

7

$().map() returns a jQuery object, not an array.
jQuery objects do not have a concat() method.

You need to call .get() to get a real array.

于 2012-09-20T02:19:45.187 回答
1

联系人是针对ARRAYS的,而不是针对OBJECTS的。使用:
1)在提交之前过滤表单参数

2)如何动态合并两个JavaScript对象的属性?

于 2015-03-31T17:04:00.753 回答