javascript anonymous function parameter passing

后端 未结 5 535
终归单人心
终归单人心 2021-02-02 13:04

I have some javascript code (within an object) :

toggle: function() {
    var me = this;
    var handler = function() { me.progress() };
    me.intervalId = setI         


        
5条回答
  •  梦毁少年i
    2021-02-02 13:20

    What you have there is a closure. The function that is created and assigned to handler keeps a reference to the me object. This is normal, everyday JavaScript, and that's the way that closures work generally.

提交回复
热议问题