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);
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);
Share
Improve this question
asked Sep 20, 2012 at 2:18
cbpcbp
25.6k29 gold badges132 silver badges211 bronze badges
2 Answers
Reset to default 8$().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.
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?