最后执行finally
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>最后执行finally</title>
<!--
finally{a}
解读:不论之前是否发生错误,错误是否被处理,最后都要执行代码a
-->
</head>
<body>
<script>
var a=1;
try{
throw "我是错误提示";//自定义error massage
}
catch (b){
console.log(b);//catch()捕获error name=b,b容纳了throw定义的error massage
}
finally{
console.log("不管前面的对错,反正最后我都要执行");//不论前面怎样,最后都要执行的代码
}
</script>
</body>
</html> 相关推荐
opspider 2020-06-28
lupeng 2020-11-14
sjcheck 2020-11-10
meylovezn 2020-08-28
owhile 2020-08-18
Francismingren 2020-08-17
pythonclass 2020-07-29
sunzhihaofuture 2020-07-19
爱读书的旅行者 2020-07-07
行吟阁 2020-07-05
tianqi 2020-07-05
行吟阁 2020-07-04
冰蝶 2020-07-04
lyg0 2020-07-04
owhile 2020-07-04
lengyu0 2020-06-28
tianqi 2020-06-21
dadaooxx 2020-06-16