What is the use of the JavaScript 'bind' method?

后端 未结 19 1941
自闭症患者
自闭症患者 2020-11-21 06:24

What is the use of bind() in JavaScript?

19条回答
  •  名媛妹妹
    2020-11-21 06:57

    The bind function creates a new function with the same function body as the function it is calling .It is called with the this argument .why we use bind fun. : when every time a new instance is created and we have to use first initial instance then we use bind fun.We can't override the bind fun.simply it stores the initial object of the class.

    setInterval(this.animate_to.bind(this), 1000/this.difference);
    

提交回复
热议问题