Javascript object max size limit at 10000 chars


When I run this code, the variable items only appends 9999 chars and rest is truncated. I got a few answers in the previous post but the problem still persists.

var items = [];
for (var i = 1; i < 400; i++) {
    items.push('{"Key":' + '"this is a javascript value"' +
                ",'+'" + '"Value"' + ':' + '"this is value"}');


Best Solution

You are alerting the value which means the array is converted to a String and then put in an alert box. Most probably, the String is cut off to some maximum length, otherwise it just won't fit on the screen or in the box for graphical reasons.

When tried in-memory and only alerting the lengths, everything seems OK, also the toString() returns the correct length. I tried 4000 elements and analyzing the lengths: