サイト内検索

Array プロパティ一覧

スポンサー

ホーム > Array > prototype

prototype

オブジェクトにプロパティを追加します.

シンタックス

object.prototype.name = value

サンプルコード

以下にprototypeプロパティを使用したサンプルコードを示します.

<html>
  <head>
    <title>prototypeプロパティのサンプルコード</title>
  </head>
  <body>
    <script type="text/javascript" language="javascript">
      /* Arrayオブジェクトにプロパティを追加 */
      Array.prototype.x = 0;
      Array.prototype.y = 0;

      var ary = new Array();
      ary.x = 1;
      ary.y = 2;

      document.write(ary.x + "<br />");
      document.write(ary.y + "<br />");
    </script>
  </body>
</html>

実行例

サンプルコードの実行結果は以下のようになります.

1
2

スポンサード リンク

inserted by FC2 system