JS object naming issue
<p>Probably a really silly question, but I can't fathom it:</p>

<p>I want to be able to create a tab by calling a function -  newTab();
I want this function to create a new tab object (that I can manipulate by doing things such as tab0.close();)</p>

<p>My problem arises in getting the object to have a unique name:</p>

<pre><code>//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
   }
}
</code></pre>

<p>I understand this may not be the best way of doing things either, so I'm open to suggestions!</p>

<p>Cheers,</p>
