javascript prototype属性


  翻訳結果:

英語 [ˈprəʊtətaɪp] 米国 [ˈproʊtətaɪp]

##n.プロトタイプ、プロトタイプ、設計図

複数形: プロトタイプ

javascript prototype属性構文

プロトタイプ属性とは何ですか?

#プロトタイプ属性は関数固有の属性であり、関数のプロトタイプ オブジェクトでもあります。プロトタイプ オブジェクトに追加された属性とメソッドは、新しいオブジェクトがインスタンス化された後、オブジェクトに継承できます。

関数:プロトタイプ属性を使用すると、オブジェクトにプロパティとメソッドを追加できます。

構文: object.prototype.name=value

javascript prototype属性例

<html>
<body>

<script type="text/javascript">

function employee(name,job,born)
{
this.name=name;
this.job=job;
this.born=born;
}

var bill=new employee("Bill Gates","Engineer",1985);

employee.prototype.salary=null;
bill.salary=20000;

document.write(bill.salary);

</script>

</body>
</html>

インスタンスの実行 »

[インスタンスの実行] ボタンをクリックしてオンライン インスタンスを表示します

人気のおすすめ

ホームページ

ビデオ

に質問