bind 用法及簡單實現原理

前言 bind 和 call/apply 同樣,都是用來改變上下文 this 指向的,不一樣的是,call/apply 是直接使用在函數上,而 bind 綁定 this 後返回一個函數(閉包),以下:javascript var obj = {     init: 1,     add: function(a, b) {         return a + b + this.init;    
相關文章
相關標籤/搜索