Skip to content

📚 7.setTime实现setInterval

💻 代码实现

typescript
// TODO:实现取消
function mySetInterval(callback, delay) {
    const recurit = () => {
        setTimeout(() => {
            callback()
            recurit()
        }, delay)
    }
    recurit()
}
mySetInterval(() => {
    console.log("111")
}, 1000)

Released under the MIT License.