异常
抛出异常
//捕获异常 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模块化