Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Defining Properties for an Object Type

あるオブジェクトの種類に対するプロパティの定義

prototype プロパティを用いて、定義済みのオブジェクトの種類にプロパティを追加することができます。この方法では、指定した種類のすべてのオブジェクトで共有されるプロパティを定義することになります。そのオブジェクトのあるインスタンス 1 つだけということではありません。次のコードは color プロパティを car という種類の全オブジェクトに追加し、値をオブジェクト car1color プロパティに代入します。

car.prototype.color=null;
car1.color="black";

詳しくは コア JavaScript リファレンス 内の Function オブジェクトの prototype プロパティ を参照してください。

ドキュメントのタグと貢献者

 このページの貢献者: ethertank, happysadman, Mgjbot, Electrolysis
 最終更新者: ethertank,