I’ve seen that can use object literal notation to define an object with a getter like so:
var foo = {
get bar() { return 3; }
}
Is there some object literal syntax that allows me to set other property descriptor attributes of “bar” above, such as ‘enumerable’?
Or, is ‘get/set‘ the only property descriptor attributes supported for ECMAScript5 object literal notation?
A good question…but I don’t think it can be done.
getandsetare defined as operators that act the same way as property descriptors:Looking through the javascript operator list I don’t see anything similar for other descriptors apart from get and set.