js中,Date是内置的一种数据类型,虽然直接输出的date格式适合人们阅读,但是对于机器程序来说却有些不方便:
var now=new Date(); console.log(now);//Wed Nov 25 2015 22:02:17 GMT+0800 (中国标准时间)
怎么转换为便于js程序来操作的形式呢?很简单只要在new关键字前面加上一个+即可:
var now=+new Date(); console.log(now);//1448460291345
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
try { foo.bar(); } catch (e) { if (e instanceof EvalError) { alert(e.name + ‘: ‘ + e.message); } else if (e instanceof RangeError) { alert(e.name + ‘: ‘ + e.message); } else if (e instanceof InternalError) { alert(e.name + ‘: ‘ + e.message); }else if (e instanceof ReferenceError) { alert(e.name + ‘: ‘ + e.message); }else if (e instanceof SyntaxError) { alert(e.name + ‘: ‘ + e.message); }else if (e instanceof TypeError) { alert(e.name + ‘: ‘ + e.message); }else if (e instanceof URIError) { alert(e.name + ‘: ‘ + e.message); } // ... etc }
原文:http://www.cnblogs.com/kidsitcn/p/4996101.html