jQuery.map(....).concat is not a function

javascript

Solution

`$().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.

Problem

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); ```

Original source

Related problems