したがって、クロージャを使用して「new」演算子を使用せずにプロトタイプの継承を持つオブジェクトを作成しようとしています。私のコードは次のとおりです。
var TABLE=function (tableId) {
var table=(document.getElementById(tableId)||{}),
colName=[],
rows,
cols,
selectedRow;
//private methods
var updateRows=function(){
//Code that updates the number of row of the table
}
updateRows();
//Declare the public methods for the object
var methods={
prototype:{
cols:function () {
return cols;
},
rows:function () {
return rows;
}
}
};
return methods;
}
var table=Table("Inventory")
alert(table.rows()) //I get undefined
alert(table.prototype.rows()) //I get the actual number of rows
私は何が間違っているのですか?あなたは私がこれのためにコーディングのいくつかのより良い方法を使うことができると思いますか
私はすべての助けに感謝します。