+對于之后的日期對象進(jìn)行加法運算硼瓣,倒是觸發(fā)了日期對象valueof()方法韧献,所以最終得到的是日期對象的毫秒數(shù)舌劳,也就是時間戳竣贪。
varnow =newDate, time =now.getTime();
console.log(time==now.valueOf());//true
console.log(time==+now);//true
+對于之后的日期對象進(jìn)行加法運算硼瓣,倒是觸發(fā)了日期對象valueof()方法韧献,所以最終得到的是日期對象的毫秒數(shù)舌劳,也就是時間戳竣贪。
varnow =newDate, time =now.getTime();
console.log(time==now.valueOf());//true
console.log(time==+now);//true