Closed rolandoam closed 12 years ago
keeping this one out for now
re-open this issue
not using defineGetter and setter, but using private properties:
var A = function (depth) {
// private properties
var a = "the a";
var b = "the b";
// public property
this.depth = depth;
// define accessor for a
Object.defineProperty(this, 'a', {
get: function () { return a; },
set: function (newA) { a = newA; console.log("in the setter"); }
});
};
I'm delaying this again until I gain a bigger understanding of how to properly implement this. After a quick tests, it seems that I would introduce a big penalty in performance for a not so big gain in API readability:
http://jsperf.com/creation-time-comparison-for-ecma5-accessors
closing this again for now
use
__defineGetter__
/__defineSetter__
instead of(set | get)PropertyName
in all the objects.