I want to experiment with some of the new ECMAScript 5 features. I would like to do some things similar to some kind of code that I found when searching on googling:
var obj = {}; Object.defineProperty( obj, "value", { value: true, writable: false, enumerable: true, configurable: true }); (function(){ var name = "John"; Object.defineProperty( obj, "name", { get: function(){ return name; }, set: function(value){ name = value; } }); })(); print( obj.value )
Perhaps this is generally possible?
Tanya source share