Hi.

I've recently been surprised with $.map. I've found that it flattens
the result so I can't return an array in the callback. For example, on
this code:

$.map([1, 2, 3], function(n) {
   return [n, 'xxx'];
});

I get:

[1, "xxx", 2, "xxx", 3, "xxx"]

Instead of what I expected:

[[1, "xxx"], [2, "xxx"], [3, "xxx"]]


Looking on the source code is obvious that this is made on purpose,
and there are workarounds, but I was curious on why this is happening.

Marc.

Reply via email to