Revision: 44407
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at April 11, 2011 09:14 by reelfernandes
Initial Code
var myObject = {}; //wrapping Object.defineProperty in a function like this feels very hacky (function() { var myProp = 'myDefault'; Object.defineProperty( myObject, 'myProp', { enumerable: false, configurable: true, get: function() { return myProp; }, set: function( v ) { myProp = v+' is mo beta'; } }); })(); alert( myObject.myProp ); myObject.myProp = 'myValue'; alert( myObject.myProp ); /* COULDN'T IT HAVE JUST BEEN.... Object.defineProperty( myObject, 'myProp', { writable: false, enumerable: false, configurable: true, value: 'myDefault', get: function() { return myProp; }, set: function( v ) { myProp = v+' is mo beta'; } }); */
Initial URL
Initial Description
Initial Title
ECMAScript 5 Getter/Setter
Initial Tags
Initial Language
JavaScript