1 .兩個時間對象時間差---相減得到時間差,結(jié)果為毫秒數(shù)
const d = new Date(time)
const now = Date.now()
const diff = (now - d) / 1000
- Math.ceil floor
取整,向上向下,字符串自動轉(zhuǎn)換
round 四舍五入
random() 0-1之間偽隨機(jī)數(shù)
1 .兩個時間對象時間差---相減得到時間差,結(jié)果為毫秒數(shù)
const d = new Date(time)
const now = Date.now()
const diff = (now - d) / 1000