ES5 Accessor Properties

I have been messing around this weekend with Object.defineProperty and realising some unanticipated behaviour when using accessor properties and prototype inheritance. Essentially it boils down to this, accessor properties are only ever owned by the Object they are defined on.

For example, if I were to do the following:

Now I hadn’t actually expected that. So you have a choice, in your constructor function, you can iterate through your prototype, looking for accessor properties and copy the property descriptor directly on the instance, or you can leave well enough alone.