function sleep(delay) {
var start = new Date().getTime();
while (new Date().getTime() - start < delay) {
console.log({}); // this works
}
}
function sleep1(delay) {
var start = new Date().getTime();
while (new Date().getTime() - start < delay) {
console.log('???') // this seems not work, why?
}
}
function test() {
console.log("111");
sleep(2000); // which works fine
sleep1(2000); // which won't stop
console.log("222");
}
test();
When the input of console.log is an object it works. But when the input changes to a number, the chrome console jams. Why does this happen?