JS clearInterval或window.clearInterval? [英] JS clearInterval or window.clearInterval?

查看:189
本文介绍了JS clearInterval或window.clearInterval?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Javascript具有用于处理异步函数调用的setInterval和clearInterval函数。

Javascript has setInterval and clearInterval functions for handling asynchronous function calls.

clearInterval(handle) window.clearInterval(句柄)

我看到它被双向使用。

推荐答案

在浏览器中,所有全局函数都是窗口对象的隐式属性。所以 clearInterval() window.clearInterval()完全相同。

In a browser, all global functions are implicitly properties of the window object. So clearInterval() and window.clearInterval() are the exact same thing.

除非你定义一个名为 clearInterval()的本地函数,否则它们之间没有区别,在这种情况下 window.clearInterval()将引用全局值, clearInterval()将引用本地值。

There is no difference between them unless you define a local function called clearInterval(), in which case window.clearInterval() would reference the global one and clearInterval() would reference the local one.

对于您自己定义的任何全局函数也是如此。

The same would be true for any global functions that you define yourself.

这篇关于JS clearInterval或window.clearInterval?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆