Proposal: Object.defineProperty shorthand

Sean Eagan seaneagan1 at gmail.com
Thu May 26 16:24:07 PDT 2011


On Thu, May 26, 2011 at 4:27 PM, Sean Eagan <seaneagan1 at gmail.com> wrote:
> Something similar could work for properties, need to think about it.

Here's a start:

// reusable descriptor
var allFalse = {configurable: false, writable: false, enumerable: false};

var foo = {
  {configurable: false} @ a: 1, // writable, enumerable default to true
  allFalse @ b: 2, // dynamic
  #!~ @ c: 3 // shorthand still works,
  # @ get x() {return "x"}
  set x() {return "x"} // only specify for get xor set, not both
}

// property assignment versions
{configurable: false} @ foo.d = 4
allFalse @ foo["e"] = 5;
#!~ @ foo.f = 6;


Thanks,
Sean Eagan


More information about the es-discuss mailing list