if中如果有返回值时,就不要写else了

if(...) {
    
    
   return 'toto'
 }else {
    
    
   return 'titi'
}

如果 if 有返回值,可以这样写

if(...) {
    
    
   return 'toto'
 }
   return 'titi'

猜你喜欢

转载自blog.csdn.net/weixin_43131046/article/details/121475265