美文网首页
JavaScript中try...catch

JavaScript中try...catch

作者: Lamport | 来源:发表于2019-08-20 18:03 被阅读0次
    try{
            aaaaa
    }catch(error){
            console.log(error);
    }
    

    1、执行结果

            aaaa is not defind

    2、执行顺序

            类似于if...else语句,try和catch只会执行一个

    3、执行方式

            try 语句允许我们定义在执行时进行错误测试的代码块。
            catch 语句允许我们定义当 try 代码块发生错误时,所执行的代码块。
            error 代表 try 语句未执行的原因

    相关文章

      网友评论

          本文标题:JavaScript中try...catch

          本文链接:https://www.haomeiwen.com/subject/pvxmsctx.html