<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                [toc] #### 1.手寫call call用法: ```js let obj = { name: "xuxu1", }; function getName() { console.log(this.name); } getName.call(obj); // xuxu ``` 手寫call思路: 1.傳入一個對象,這個作為新this的指向 2.將調用的方法也就是老的this指向這個對象 3.執行調用的方法 ```js Function.prototype.mCall = function(obj, ...args) { // 綁定 this 到新的對象上 const newObj = obj || window const key = Symbol() // 定義一個唯一 key newObj[key] = this // 執行,傳遞后面的參數,并返回結果 const res = newObj[key](...args) // 刪除給源對象綁定的 key delete newObj[key] return res } ``` #### 2.手寫apply,apply接受的參數是數組 ```js Function.prototype._apply = function(context, args) { const newObj = context || window let key = Symbol() newObj[key] = this // 把方法賦值給 context,作為一個屬性值 newObj[key](args) console.log(args) delete newObj[key] } ``` #### 3.手寫 bind ```js Function.prototype.myBind = function(context, ...args) { // 獲取當前方法 const self = this // 返回一個新函數,將 this指向綁定到 context const fn = function(...rest) { return self.call(context, ...args, ...rest) } // 如果原方法上存在原型,添加原型到新的方法上 if (self.prototype) { fn.prototype = Object.create(self.prototype) } return fn } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看