After trying out various techniques for creating JavaScript arrays, I came across an unexpected outcome. By utilizing map
to push
an array of self-references (DEMO):
a=[1,1,1,1,1,1,1,1,1,1];
a=a.map(a.push,a);
I ended up with the following result (when using Chrome):
[13,16,19,22,25,28,31,34,37,40]
Could someone provide an explanation for this behavior?