JavaScript オブジェクト 新しいページはコチラ

提供: yonewiki
移動: 案内, 検索
(prototype.isPrototypeOf() メソッド)
(hasOwnProperty() メソッド)
672行: 672行:
 
サンプル
 
サンプル
 
<syntaxhighlight lang="javascript" line start="1">
 
<syntaxhighlight lang="javascript" line start="1">
 +
<HTML>
 +
<HEAD>
 +
<TITLE>JavaScript メソッド.hasOwnProperty()</TITLE>
 +
</HEAD>
 +
<BODY>
 +
JavaScript メソッド.hasOwnProperty()<br />
 +
<SCRIPT Language="JavaScript">
 +
<!--
  
 +
function Func1(){
 +
    this.property_nValue1 = 100;
 +
}
 +
function Func2(){
 +
    this.property_nValue2 = 100;
 +
}
 +
 +
Func1.prototype = new Func2();
 +
Func2.prototype.property_nValue3 = 200;
 +
 +
objFunc = new Func1();
 +
 +
document.write("■hasOwnProperty()<BR />");
 +
document.write(objFunc.hasOwnProperty("property_nValue1"), "<BR />");
 +
document.write(objFunc.hasOwnProperty("property_nValue2"), "<BR />");
 +
 +
document.write("<BR />");
 +
 +
document.write("■in<BR />");
 +
document.write("property_nValue1" in objFunc, "<BR />");
 +
document.write("property_nValue2" in objFunc, "<BR />");
 +
-->
 +
</SCRIPT>
 +
</BODY>
 +
</HTML>
 
</syntaxhighlight>
 
</syntaxhighlight>
 
[[Media:JavaScript Object hasOwnProperty.html|実行結果サンプル]]
 
[[Media:JavaScript Object hasOwnProperty.html|実行結果サンプル]]

2016年2月25日 (木) 00:00時点における版



個人用ツール
名前空間

変種
操作
案内
ツールボックス