[js] create proper closure for Array.push (closes #1997)

See #1997
Is this generated in the right place? It is going to "regenerate" the x expression at each pass. Maybe using:

    print ctx "Array.prototype.push.bind(";
    gen_value ctx x;
    print ctx ")";

If we don't have the .bind polyfill or a replacement for it I think the solution is a little more involved.