Accessing the prototype of an object

Prototypes can be accessed in three different ways:

  • Person.prototype
  • Object.getPrototypeOf(person)
  • person.__proto__
The use of __proto__ is controversial and has been discouraged by many experienced software engineers. It was never originally included in the ECMAScript language specification, but modern browsers decided to implement it anyway. Today, the __proto__ property has been standardized in the ECMAScript 6 language specification and will be supported in the future, but it is still a slow operation that should be avoided if performance is a concern.

Get Learning TypeScript 2.x - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.