js实现sleep功能

function sleep(numberMillis) {

    var now = new Date();

    var exitTime = now.getTime() + numberMillis;

    while (true) {

        now = new Date();

        if (now.getTime() > exitTime)

        return;

    }

}

你可能感兴趣的:(js,sleep)