try/catch/finally

The try/catch/finally statement is JavaScript’s exception handling mechanism.

try/catch/finally语句是js的异常处理机制。

 

The
try clause of this statement simply defines the block of code whose exceptions are to
be handled. The try block is followed by a catch clause, which is a block of statements
that are invoked when an exception occurs anywhere within the try block. The catch
clause is followed by a finally block containing cleanup code that is guaranteed to be
executed, regardless of what happens in the try block.

try语句指定代码块,这些代码块的异常需要被处理。当try代码块中的异常发生时,catch代码块被调用。finally块中包含清理代码,不管try块中发生什么,finally代码块一定会执行。

 

Both the catch and finally
blocks are optional, but a try block must be accompanied by at least one of these blocks.
The try, catch, and finally blocks all begin and end with curly braces. These braces
are a required part of the syntax and cannot be omitted, even if a clause contains only
a single statement.

转载于:https://www.cnblogs.com/sunhe/p/4347305.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值