This is a quick post relating to a Rhino bug I've just fallen foul of. This probably isn't very interesting for most folk, but if you've come here from Google then hopefully I can help you out!

Let's start with a definition (from the excellent MDN) of how the delete operator should behave in relation to properties found on the prototype

"You cannot delete a property on an object that it inherits from a prototype (although you can delete it directly on the prototype)."

It even goes on to give an example -

function Foo(){} = 42;
var foo = new Foo();
delete; // but doesn't do anything
alert(; // alerts 42, property inherited
delete; // deletes property on prototype
alert(; // alerts "undefined", property no longer inherited

Unfortunately, after lots of head scratching, it turns out this is not how things work in Rhino (<=1.7R2). The above code, modified to print rather than alert, prints "undefined", "undefined". Rhino is walking the prototype chain to find the property and then deleting it from the prototype. This is because of the following bug Bug 510504 - delete foo.prop should not walk the property chain to find prop.

The bug was fixed and released in 1.7R3 which can be found at a slightly different location from 1.7R2 -


Upgrading to that version prints "42", "undefined" - success!