Wanted: standard Array function to append an array's elements to another array

Andrea Giammarchi andrea.giammarchi at gmail.com
Fri Jul 29 05:22:22 PDT 2011


to avoid apply limits is actually trivial:

var fromCharCode = (function ($fromCharCode, MAX_LENGTH) {
    return function fromCharCode(code) {
        typeof code == "number" && (code = [code]);
        for (var
            result = [],
            i = 0,
            length = code.length;
            i < length; i += MAX_LENGTH
        ) {
            result.push($fromCharCode.apply(null, code.slice(i, i +
MAX_LENGTH)));
        }
        return result.join("");
    };
}(String.fromCharCode, 2048));

// example
alert(fromCharCode(80)); // P
alert(fromCharCode([80,81,82,83,84])); // PQRST

about the pushAll I wonder if concat does not do already exactly what you
are looking for, as I wrote in the other thread.

Best Regards,
    Andrea Giammarchi

On Mon, Jul 25, 2011 at 10:17 PM, Jeff Walden <jwalden+es at mit.edu> wrote:

> It's perhaps worth noting that this problem also occurs with
> String.fromCharCode.  I suspect the need for a version of
> |String.fromCharCode.apply(**null, codesArray)| that always works, even
> for super-big |codesArray|, is rather smaller than for the similar
> Array.prototype.push concern.
>
>
> Jeff
> ______________________________**_________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/**listinfo/es-discuss<https://mail.mozilla.org/listinfo/es-discuss>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110729/3f2881dc/attachment.html>


More information about the es-discuss mailing list