Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9121221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:48:41+00:00 2026-06-17T05:48:41+00:00

Consider the following: var foo = [] for (var i=0; i<100000; i++) { foo.push(97);

  • 0

Consider the following:

var foo = []
for (var i=0; i<100000; i++) { foo.push(97); }
var bar = String.fromCharCode.apply(String,foo)

Most browsers run it fine, but Safari throws: RangeError: Maximum call stack size exceeded.

Based on this, it appears that Safari’s implementation of Function.prototype.apply is recursive. Is this true?

The MDN page linked above mentions potential issues with the JS engine’s argument length limit, but that’s clearly not the case here.

EDIT: I still don’t think it’s an argument length issue. Via this page and my own testing, it looks like Safari can handle up to 524197 arguments, which the above code does not exceed.

Bonus question: We can rewrite the above code to avoid using apply by explicitly calling String.fromCharCode on each element of the array and joining the results together, but I suspect that would be slower (for the browsers that support the large-input apply). What’s the best way to assemble a large string from an array of integer character codes?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:48:42+00:00Added an answer on June 17, 2026 at 5:48 am

    Apply has limits in some browsers in the length of arguments they accept. Webkit has an observed limit of 2^16, so if you have any need to have more you may want to follow a strategy to break up the arguments. If you read the details of the bug, it’s an enforced limitation opposed to it being a problem arising from recursion (the bug in question also threw a similar RangeError).

    Anyway, I believe your hunch about string concatenation was correct – join isn’t necessarily as good as other methods. Here’s a test against string concat where I first break up the arguments (similar to the strategy in the MDN discussion of apply), and it edges out join. Directly adding string together even edged out join, which I’m a little surprised by (in chrome, at least, I’d imagine they must just have some smart gc that can reuse the existing string to great effect, but can say for sure).

    Edit – interestingly, it looks like Chrome is the odd one out in terms of how slow join is – for every other browser, it was much closer to concat in terms of performance or even better.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following code: class Foo(var name: String = bar) Now i try to
Consider the following: var o = new { Foo = foo, Bar = bar
Consider the following JavaScript: for (var i = 0; i < foo.length; i++) {
Consider the following example : <input type=text id=#ab>cd.ef value=foo /> <script type=text/javascript> var id
Consider the following JPQL query: SELECT foo FROM Foo foo INNER JOIN FETCH foo.bar
Consider the following code: var myDict = new Dictionary<string, int>(); myDict.Add(Key1, 1); myDict.Add(Key2, 2);
The following code: var things = {'foo':'bar'} for ( thing in things ) {
Consider the following HTML: <div class=foo id=obj> I should be changed red <div class=bar
Consider the following two snippets, with braces: switch (var) { case FOO: { x
consider the following: var service_call_array = { 3 : 'test', 4 : 'more of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.