네트워크/웹 프로그래밍(클라이언트)
자바스크립트 setTimeout(function, ms)
khao
2016. 7. 14. 20:01
SetTimeout( function, mile second)
일정시간 딜레이를 가진 뒤 입력한 함수를 호출한다.
이때 호출되는 함수는 쓰레드를 사용한 것처럼 호출된다.
function delay(gap) {
var then, now;
then = new Date().getTime();
now = then;
while( (now - then) < gap ) {
now = new Date().getTime();
}