var start = Date.now();var response = prompt("What is your name?", "");var end = Date.now();var elapsed = (end - start) / 1000;document.write("You took " + elapsed + " seconds" + " to type: " + response);为什么start和end都是Date.now()? 还有elapsed=(end-start)/1000是什么意思啊?
1 回答
冉冉说
TA贡献1877条经验 获得超1个赞
Date.now()
都是取当前时间啊
end和start执行的时间不同可以取出时间差得出花费了多少时间
var start = Date.now();
setTimeout(function(){
var end = Date.now();
console.log(end-start);
},2000);
添加回答
举报
0/150
提交
取消