Can't do push in forEach

Emanuel Allen emanuelallen at hotmail.com
Thu May 14 14:25:10 UTC 2015


Surprise that I can't do arr1.forEeach(arr2.push);

Will throw an error.

Using bind as:

push = arr2.bind(push); 
arr1.forEeach(push);

Works... And not work. Seem to push individual elements and after every second element, it'll push the hold array.. And after and before each index that hold the array there are duplicate of that element preceding and following:

[1,2,array,2,3]//not this is with shift method
[1,2,array,3,2]//note that this is with push


JS4L


More information about the es-discuss mailing list