Error
// 语法 throw new Error("消息"); 类似于C#中的Exception对象 // alert(num); try { throw new Error("num is not defined"); } catch (e) { alert(e); } // 常用 try { throw {msg:"错误异常", dateTime:new Date()}; } catch (e) { alert(e.msg + "\r\n" + e.dateTime); } // 同c#的try-catch-finally写法 try { } catch (e) { } finally { // 释放资源 }
Math
常用的有一个创建随机数的方法
Math.random() 产生0 到 1 之间的数,位数不定。