On 10/3/13 9:34 AM, Domenic Denicola wrote: > Oh! It's just like ES5 object literals. A getter without a setter means no setter. The answer is `undefined`. Note that I was asking about the other way around: a setter with no getter. I assume that's what you were talking about too. That doesn't work, then. Consider this testcase, which sets up this situation: var objWithGetter = { get x() { return this._x; } } var objWithSetter = Object.create( objWithGetter, { "x": { set: function(arg) { this._x = arg; } } } ); function MyConstructor() { this._x = 0; } MyConstructor.prototype = objWithSetter; var testObj = new MyConstructor(); print(testObj.x); testObj.x = 17; print(testObj.x); This prints "undefined" twice (as exspected, because the undefined getter on objWithSetter shadows the getter we really want), whereas the obvious desired behavior is to print 0 and then 17. The point being, this is not a useful way to have a common superclass that's immutable and has the getters and a subclass with the setters, because due to how accessor descriptors work in ES those setters end up shadowing the getters. :( -BorisReceived on Thursday, 3 October 2013 16:11:23 UTC
This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:18 UTC