Rhino Prompt…

js> a[0] = 1;
js> a.print = function () {for(var e in this) print ("a[" + e + "] = " + a[e]);};

function () {
    for (var e in this) {
        print("a[" + e + "] = " + a[e]);
    }
}

js> a.print();
a[0] = 1
a[print] =
function () {
    for (var e in this) {
        print("a[" + e + "] = " + a[e]);
    }
}

Post to Twitter