2018
06-20
06-20
try-catch-finally,被你忽略掉的执行顺序
try-catch是捕捉异常的神器,不管是调试还是防止软件崩溃,都离不开它。今天笔者介绍一下加上finally后的执行顺序functiontest(){try{console.log(1);}finally{console.log(2);}}console.log(test());//12嗯!按顺序执行了。我们在try中加入return语句functiontest(){try{console.log(1);return'from_try';}catch(e){//TODO}finally{console.log(2);}}console...
继续阅读 >