Day 5 "a time Functions"

Hector·2023년 3월 24일
0

Vanilla JavaScript

목록 보기
5/14
**function kind **
<script>
// Declaration(선언)
function Dec(){
    console.log('a declarat function');
}

// Assignment(할당)
const assIng = function (){
    console.log('Assigning a Variable function');
};

// anonymous function(익명함수)
(function (){
    console.log('Anonymous function');
})();

Dec();
assIng();
</script>

Definition

<script>
// a time functions(시간 함수)

// Execute a function after a certain amount of time(일정 시간 후에 함수를 실행)
let timer = setTimeout( function (){
    console.log('')
},5000);


// Execute a function over a period of time(일정 간격 동안 함수를 실행)
let loop = setInterval(()=>{
    console.log('Repeat')
},1000);

const stopTimer = function(){
    clearTimeout(timer);
}

const stopLoop = function(){
    clearInterval(loop);
}
console.log(1)
console.log(2)
console.log(3)
console.log(4)
console.log(5)
</script>
<script>
let second = 1;
let timerid;
    timerid = setInterval(function(){
    console.log(second++)
    if(second > 60){
       clearInterval(timerid)
      }
      },1000)
let timer = setTimeout(function(){
    console.log('boing!')
    },61000)
</script>
profile
I`m Studying Bankend

0개의 댓글