We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在书写代码时,优先处理特殊情况或者异常情况,其次再处理正常情况。
这么做的好处就是如果遇到特殊或者异常情况能快速执行完代码,同时书写更清晰。
//原始代码 if(condition){ //中间有100行代码 }else{ //这里只有1行代码! };
以上逻辑最好的书写规范是:
if(!condition){ //1行代码! return; }; //剩余100行代码
(全文完)
The text was updated successfully, but these errors were encountered:
sunmaobin
No branches or pull requests
JS最佳实践-代码书写时异常情况先行
最佳实践
在书写代码时,优先处理特殊情况或者异常情况,其次再处理正常情况。
好处
这么做的好处就是如果遇到特殊或者异常情况能快速执行完代码,同时书写更清晰。
示例
以上逻辑最好的书写规范是:
(全文完)
The text was updated successfully, but these errors were encountered: