I have some simple jQuery code:
var response = Array()
$('.task-list').each(function() {
response.concat(response,$('#' + this.id).sortable('toArray'));
}
);
console.log(response);
The problem I’m having is that I think I’m using concat improperly- the result is an empty array. When I use array push, it works correctly.
You have to set
responseto the newly formed array, as described in the specification. You currently don’t use the return value at all.The specification says that for
.concat, the array is not altered, but the new array is returned:Compare with
.push, which says the current array is altered, and that something else is returned instead (the new length):So: