Revision: 44408
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at April 11, 2011 10:01 by reelfernandes
Initial Code
var myObject = {}; Object.defineProperty( myObject, '_myProp', { value: 'myDefault', writable: false, enumberable: false, configurable: true }); Object.defineProperty( myObject, 'myProp', { enumberable: true, configurable: true, set: function( v ) { Object.defineProperty( this, '_myProp', { writable:true } ); this._myProp = v; Object.defineProperty( this, '_myProp', { writable:false } ); }, get: function() { return this._myProp; } }); alert( myObject.myProp ); myObject.myProp = 'myValue'; alert( myObject.myProp ); myObject._myProp = 'teehee, not writable'; alert( myObject._myProp );
Initial URL
Initial Description
Initial Title
ECMAScript 5 Getter/Setter Alt
Initial Tags
Initial Language
JavaScript