0

I was reading this code:

enter code here

table.onclick = function(event) {
  let td = event.target.closest('td');
  **if (!td) return;
  if (!table.contains(td)) return;**
  detail(td); 
};

But i dont undestand why there is no Curly braces in if statement. Why there is no else part. Also I dont know what the return means in one line if statement. What does this code mean.

Shahab 570
  • 27
  • 6
  • 1
    If you only have one line of code in a "block" you don't need the curly braces, only when it's an actual block of code. Else is never required, that's only to catch all other cases, in case that is required. – Brunis Sep 05 '20 at 05:50
  • Just for the future - those ** bold stars confuse your question – sheriffderek Sep 05 '20 at 06:10

0 Answers0