News for hackers. Stuff that matters.
Re:Understanding "Prototypes" in JavaScript by shmageggy on Sunday August 14, 2011 @01:40AM (#2882887)
I like how you illustrate in a clear way something that is unintuitive for people coming from a more traditional class-based background; the scoping of this.

It's easy to see how it applies locally to descendants of the original object, such as here:

  var person = Object.create(null);
  defineProperty(person, 'fullName', function() {
    return this.firstName + ' ' + this.lastName;
  });
where neither fullname nor person even have those properties, but their descendents do.

There are no comments on this comment yet.