Starting with JavaScript 1.8.5, you can use the Object defineProperty method:
Object.defineProperty (object, propertyName, attributes);
Where attributes is a map in which you can set various attributes such as value , enumerable and writable . If a property exists, it changes; otherwise, it is created.
Yuri Zaitsev built an ECMAScript 5 compatibility table where you can find browsers that support defineProperty (and many other functions), although Safari does not support defineProperty for DOM objects - just against IE! :( -
EDIT
Yuri updated the table.
source share