title: Javascript assigning value to variable
body: <p>I am trying to make a cell in a table tell me its number when I click it.</p>
  
  <pre><code>for(var j = 0; j &lt; 8; j++){
      var cell = row.insertCell(j);
      cell.name = j;
      cell.onclick=function(){alert(cell.name)};
  }
  </code></pre>
  
  <p>This however, prints the number 8 for every cell. How do I save the value of <code>j</code> in <code>cell.name</code>, instead of just having it point to the variable <code>j</code>?</p>
  
  <p>Thanks.</p>