[JavaScript] ํƒ€์ด๋จธ ํ•จ์ˆ˜

2022. 3. 22. 21:35
  • setTimeout(ํ•จ์ˆ˜, ์‹œ๊ฐ„) : ์ผ์ • ์‹œ๊ฐ„ ํ›„ ํ•จ์ˆ˜ ์‹คํ–‰
  • setInterval(ํ•จ์ˆ˜, ์‹œ๊ฐ„) : ์‹œ๊ฐ„ ๊ฐ„๊ฒฉ๋งˆ๋‹ค ํ•จ์ˆ˜ ์‹คํ–‰
  • clearTimeout() : ์„ค์ •๋œ Timeout ํ•จ์ˆ˜๋ฅผ ์ข…๋ฃŒ
  • clearInterval() : ์„ค์ •๋œ Interval ํ•จ์ˆ˜๋ฅผ ์ข…๋ฃŒ
setTimeout(function () {
  console.log('timer')
}, 3000);

const timer1 = setTimeout(() => {
  console.log('timer')
}, 3000);

const timer2 = setInterval(() => {
  console.log('timer')
}, 3000);

const h1El = document.querySelector('h1')
h1El.addEventListener('click', () => {
  clearTimeout(timer2)
})
728x90

'๐Ÿ“ฃ์–ธ์–ด > JavaScript' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[JavaScript] ์ •๊ทœํ‘œํ˜„์‹ (RegExp)  (0) 2022.03.23
[JavaScript] this  (0) 2022.03.22
[JavaScript] ์ฝœ๋ฐฑ (callback)  (0) 2022.03.22
[JavaScript] ํ˜ธ์ด์ŠคํŒ… (Hoisting)  (0) 2022.03.22
[JavaScript] DOM API : Document Object Model API  (0) 2022.03.17

BELATED ARTICLES

more