オブジェクトの作成元の参照を取得します.
object.constructor
以下にconstructorプロパティを使用したサンプルコードを示します.
<html>
<head>
<title>constructorプロパティのサンプルコード</title>
</head>
<body>
<script type="text/javascript" language="javascript">
function func01() {
document.write("Hello!<br />");
}
/* constructorプロパティの値を表示 */
document.write(func01.constructor + "<br />");
if (func01.constructor == Function) {
document.write("Functionオブジェクト");
} else {
document.write("Functionオブジェクト以外");
}
</script>
</body>
</html>
サンプルコードの実行結果は以下のようになります.
function Function() { [native code] } Functionオブジェクト
スポンサード リンク