private attributes in objects

memolus at googlemail.com memolus at googlemail.com
Sun Oct 11 12:23:50 PDT 2009


Currently I do use such kind of prototypes:

person = new function(name) {
  this.name = name;
}
person.prototype = new function() {
  /* Private */
  var id;

  /* Public */
  this.name = "";
  this.age = 0;
  this.location = "US";
}

The problem is I won't be able to use getter and setter when the new
Ecmascript arrives. But if I switch to object definitions for
prototype I won't be able to use private attributes anymore.
I propose to allow

person.prototype = {
  /* private */
  var id,

  /* public */
  name: "",
  age: 0,
 location: "US"
}


More information about the es-discuss mailing list