首页 > 解决方案 > 我不理解 javascript 中的 if else 语句。谁能解释一下?

问题描述

我正在阅读这段代码:

enter code here

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

但我不明白为什么 if 语句中没有花括号。为什么没有其他部分。我也不知道一行 if 语句中的 return 是什么意思。这段代码是什么意思。

标签: javascripthtmlcssif-statementweb

解决方案


推荐阅读