get id of clicked element javascript

JavaScript
<div onclick="doSomething(this)"></div>
function doSomething(clickedElement) {
   console.log(clickedElement);//I was clicked
}<button id="3" onClick="reply_click(this.id)">B3</button>
    
<script type="text/javascript">
  function reply_click(clicked_id)
  {
      alert(clicked_id);
  }
</script>
Source

Also in JavaScript: