Reputation: 25638
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);
Upvotes: 5
Views: 2759
Reputation: 56527
contact is for ARRAYS, and not for OBJECTS.
Use:
1) Filter Form Parameters Before Submitting
Or
2) How can I merge properties of two JavaScript objects dynamically?
Upvotes: 1
Reputation: 887957
$().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.
Upvotes: 8