Inline function call automatic element by id

Viewed 95

I have a curiosity to ask, why by inserting the id directly in the onclick function, for example, the table is recalled?

function See(table){
  console.log(table); // how system catch automatic the element?
}
<table id='iamtable' border="1">
  <thead>
    <th>Column 1</th>
    <th>Column 2</th>
    <th>Column 3</th>
    <th></th>
  </thead>
  <tbody>
    <tr>
      <td>Value</td>
      <td>Value</td>
      <td>Value</td>
      <td><button onclick='See(iamtable);'>press me</button>
    </tr>
  </tbody>
</table>

1 Answers

setting an id to an element, creates a reference in window object. you can use

window.theid // or short theid

instead of

document.getElementById('theid')

though this is not recommended

Related