[Harmony classes] method lexical scope for InstancePropertyDefinitions, PrototypePropertyDefinitions?

Luke Hoban lukeh at microsoft.com
Tue Jun 14 18:19:37 PDT 2011

 >> This is probably a dumb question but... In which case can a private property of another object be accessed?

I believe private is expected to be class-private, not instance-private, so examples like this would access privates of objects other than 'this':

class Point {
  constructor(x,y) {
    public x = x;
    public y = y;
  public equals(other) {
    return private(this).x === private(other).x && private(this).y === private(other).y;

There may also be cases where 'var that = this' style patterns are needed so that private accesses are via 'that' inside nested closures.


More information about the es-discuss mailing list