vendredi 4 septembre 2020

I don't understand one liner if else statement in javascript. Can anyone explain? [duplicate]

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.

Aucun commentaire:

Enregistrer un commentaire