[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 |