JS语法---异常和模块化

和自甴很熟 提交于 2019-11-27 08:10:46

异常

抛出异常

 

//捕获异常
try{
    // throw new Error('new error');
    // throw new ReferenceError('new error');
    // throw new 1; 
    //下面类型不报错,正常抛出
    // throw new Number(100);
    // throw 'not ok';
    // throw [1,2,3];
    // throw {'a':1};
    throw () => {};
}catch(error){
    console.log(error)
    console.log(error.constructor.name);
}finally{
    console.log('===end===')
}

模块化

ES6模块化

 

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!