Javascript's Closures - "I need your help, please !!!"
 
 
                    Thức Nguyễn Quy
                 
                    Đã trả lời thg 3 8, 2019 7:56 SA
                
Bạn có thể tham khảo hàm này
var a = countdown();
a();
  function countdown() {
  var seconds = 5;
  return function(){
   if (seconds != -1) {
   		console.log(seconds)
        seconds--;
      	setTimeout("a()", 1000);
   }else{
   		console.log("time out")
   }
  }
}
 
        +2
     
Tổ chức
Chưa có tổ chức nào.
 
 