JavaScript 制御構造 新しいページはコチラ
提供: yonewiki
(→オブジェクト 生成) |
(→オブジェクト 生成 new) |
||
| 550行: | 550行: | ||
サンプル | サンプル | ||
<syntaxhighlight lang="javascript" line start="1"> | <syntaxhighlight lang="javascript" line start="1"> | ||
| + | <HTML> | ||
| + | <HEAD> | ||
| + | <TITLE>JavaScript オブジェクト 生成 new</TITLE> | ||
| + | </HEAD> | ||
| + | <BODY> | ||
| + | JavaScript オブジェクト 生成 new<br /> | ||
| + | <SCRIPT Language="JavaScript"> | ||
| + | <!-- | ||
| + | function objNewCreate(){ | ||
| + | this.Num = 5000; | ||
| + | } | ||
| + | objNewCreate1 = new objNewCreate(); | ||
| + | |||
| + | document.write("■オブジェクトにぶら下げた変数プロパティの出力<br />"); | ||
| + | document.write("objNewCreate1.Num = " + objNewCreate1.Num + "<br />"); | ||
| + | |||
| + | dateToday = new Date(); | ||
| + | |||
| + | document.write("■Dateオブジェクトのプロパティの出力<br />"); | ||
| + | document.write("dateToday = " + dateToday + "<br />"); | ||
| + | |||
| + | --> | ||
| + | </SCRIPT> | ||
| + | </BODY> | ||
| + | </HTML> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Media:JavaScript SeigyoKozo object.html|実行結果サンプル]] | [[Media:JavaScript SeigyoKozo object.html|実行結果サンプル]] | ||