Hacker News new | ask | show | jobs
by bartq 2541 days ago
You can also play with Vanillin: http://metaes.org/playground.html#6-For%20statement%20-%20ba...

Paste this and run:

  <script>
    const rows = 100,
      cols = 10,
      table = Array.from({ length: rows }).map((_, i) => Array.from({ length: cols }).map((_, j) => ({ i, j })));
    console.log(table);
    setInterval(function() {
      let cell = table[Math.floor(Math.random() * rows)][Math.floor(Math.random() * cols)];
      cell.i = Math.floor(Math.random() * 100);
      cell.j = Math.floor(Math.random() * 100);
    }, 1);
  </script>

  <table>
    <tr for="let row of table">
      <td for="let cell of row" bind>cell.i + ":" + cell.j</td>
      <td></td>
    </tr>
  </table>

It only updates DOM element textContent on each change.