定時器:jquery
js定時器有兩種方法:setInterval(func,毫秒)和setTimeout(func,毫秒)函數
區別:setInterval()是間隔週期無限循環直到清除,而setTimeout()只執行一次,因此使用定時器是否循環就能夠甄別選擇this
相同:都是先間隔指定的毫秒後執行函數spa
this:.net
js中this和jquery中thiscode
相同點:都是按照誰調用的就指向誰。blog
案例1:get
var name = "jack"; var getName=function() { return this.name; } var entity = { name: "rose", getName: getName }; console.log(getName());//打印出的是jack console.log(entity.getName());//打印出的是rose
參考資料:https://blog.csdn.net/weixin_41615439/article/details/88697292it