0
可能是一個非常愚蠢的問題,但我不能完全理解它:通過調用函數JS對象命名問題
我希望能夠創建一個標籤 - NEWTAB(); 我想這個函數來創建一個新的標籤對象(即我可以做的事情,如tab0.close()操作;)在獲得的對象有唯一的名稱
我的問題出現了:
//This will be used for the object ID
var tabQty = 0;
//Call to create a tab
newTab();
//Function to make the tab
function newTab(){
//This is how I want to make the names - tab0, tab1, tab2 etc
tabName = "tab" + tabQty;
// - this is my problem line - I can't use tabName = as it just overwrites the value of tabName. How do I get around this?
return tabName = new tabBuilder(tabName);
}
function tabBuilder(tabName){
return{
name: tabName,
close: function(){//blah}
//More to come here
}
}
我知道這可能不是做事的最佳方式,所以我願意接受建議!
乾杯,