一、提前return,去除不必要的else 如果 if-else 代码块包含 return 语句,可以将不符合条件的情况提前return,去掉多余的else。 优化前: if (condition) { const a = 300 } else { return; } 优化后: if (!condition)