翻訳者レビュー ( 英語 → 日本語 )
評価: 68 / ネイティブ 日本語 / 0 Reviews / 2013/09/28 11:51:40
Note: that is two underscores, followed by the five characters "proto", followed by two more underscores.
When an object is created, its __proto__ property is set to reference the same object as its internal [[Prototype]] (i.e. its constructor's prototype object). Assigning a new value to __proto__ also changes the value of the internal [[Prototype]] property, except where the object is non–extensible.
To understand how prototypes are used for inheritance, see the MDN article Inheritance and the prototype chain.
In the following, a new instance of Employee is created, then tested to show that its __proto__ is the same object as its constructor's prototype.
注意:2つのアンダースコア(_)、続けて"proto"の5文字、その後さらに2つのアンダースコアである。
オブジェクトが作成されると、その __proto__プロパティは、そのオブジェクトの内部の[[Prototype]](つまり、コンストラクタのプロトタイプ オブジェクト)として参照に設定される。オブジェクトが拡張不能である場合を除き、__proto__に新しい値を割り当てることによっても、内部[[Prototype]]プロパティの値が変化する。
プロトタイプが継承においてどのように使用されるかを理解するには、MDNの「Inheritance and the prototype chain(継承とプロトタイプ チェーン)」という記事を参照。
以下のコードでは、Employeeの新しいインスタンスが作成され、その後__proto__はそのコンストラクタのプロトタイプと同じオブジェクトであることを示すためのテストが行われている。