News for hackers. Stuff that matters.
Re:Do you really know JavaScript? by Kerrick on Friday January 31, 2014 @08:58PM (#7160518)
To be honest, I spent half an hour today debugging some JavaScript I'd written recently that looked something like this:

    var array = ["a", "b"];
    var otherArray = ["c", "d"];
    otherArray.forEach(array.push, array);
    console.log(array);
I expected array to become ["a", "b", "c", "d"], but it actually becomes ["a", "b", "c", 0, <Array>, "d", 1, <Array>]. This is because Array#push accepts 1 through n arguments, not just 1 argument.

(I couldn't use Array#concat for reasons that don't show up in this simplified example.)

Re:Do you really know JavaScript? by TheZenPsycho on Friday January 31, 2014 @09:10PM (#7160549)
push was designed and made about a decade before "forEach".

Your code sample is not surprising or obscure to someone who has skimmed documentation on "push" and "forEach"