ダグラスJavaScriptの良いパーツに語ったように、私は私は(javascript配列関数array.methodを作成することができます)
Array.method('reduce', function (f, value) {
});
、以下のようにアレイ法を作成しようとしましたが、私は
を取得していますUncaught TypeError: Array.method is not a function at :1:7
ダグラスJavaScriptの良いパーツに語ったように、私は私は(javascript配列関数array.methodを作成することができます)
Array.method('reduce', function (f, value) {
});
、以下のようにアレイ法を作成しようとしましたが、私は
を取得していますUncaught TypeError: Array.method is not a function at :1:7
Array
にはmethod()
はありません。 ダグラス・クロフトフォードの投稿では、彼はその方法を自分で作成して使用しています。
これは、あなたが20ページの "単純なテスト・グラウンド" というタイトルのセクションを読み取るために必要なコード
Object.prototype.method = function (name, func) {
this.prototype[name] = func;
return this;
};
です:
Throughout the book, a method method is used to define new methods. This is its definition:
Function.prototype.method = function (name, func) { this.prototype[name] = func; return this; };
It will be explained in Chapter 4.