I am wanting to experiment with some of the new ECMAScript 5 features. I would like to do some stuff similar to some code I found when 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 )
// true
print( obj.name );
// John
obj.name = "Ted";
print( obj.name );
// Ted
Is any of this possible at all yet??
Here is a great compatibility table: http://kangax.github.com/es5-compat-table/
For completeness, there are also tables for ECMA6 and non-standard features.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With