Closed c69 closed 12 years ago
This is by design, click "getter" to evaluate.
Sorry, read this too fast, this is clearly a problem. Reopening.
No, closing again. I can't find it in the spec, but when you specify only a setter, a getter is automatically created with the value undefined. This is what you see.
ok, but How can i inspect a setter then ?
Not sure what you mean by inspect a setter. I don't think you can obtain reference to the function that runs on setting value, if that's what you mean.
One might argue that 'getter' is a poor name for what not necessarily has to be a getter, in ecmascript sense. It could be a property that is just not 'trivial' to obtain and thus requires manual evaluation to get the value. Maybe we should rename 'getter' to 'fetch' or 'retrieve' for example.
You can do a.__lookupSetter__("z")
which returns the setter or Object.getOwnPropertyDescriptor(a, "z")
which returns an object with configurable
, enumerable
, get
and set
.
Thanx for the tip, this works.
var a = { b: 1, get x () { return this.b; }, set z (v) { return (this.b = v); } }
When we inspect 'a' in console - we see:
[-] Object b 1 x getter z getter