第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

bind方法不是棄用了嗎?

bind方法不是棄用了嗎?

正在回答

2 回答

jquery的事件綁定方法.bind(),和視頻所講的js原生修改函數(shù)this指向的.bind(),是兩個(gè)東西啊。大兄弟,你會(huì)不會(huì)把這兩者混淆了~

0 回復(fù) 有任何疑惑可以回復(fù)我~

bind?函數(shù)在 ECMA-262 第五版才被加入;它可能無法在所有瀏覽器上運(yùn)行。你可以部份地在腳本開頭加入以下代碼,就能使它運(yùn)作,讓不支持的瀏覽器也能使用 bind() 功能。

if (!Function.prototype.bind) {
?Function.prototype.bind = function (oThis) {
? ?if (typeof this !== "function") {
? ? ?// closest thing possible to the ECMAScript 5
? ? ?// internal IsCallable function
? ? ?throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable")
? ?}

? ?var aArgs = Array.prototype.slice.call(arguments, 1),
? ? ?fToBind = this,
? ? ?fNOP = function () {},
? ? ?fBound = function () {
? ? ? ?fBound.prototype = this instanceof fNOP ? new fNOP() : fBound.prototype ? ? ? ?return fToBind.apply(this instanceof fNOP
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? this
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? : oThis || this,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? aArgs.concat(Array.prototype.slice.call(arguments)))
? ? ? ?}
? ?if( this.prototype ) {
? ? ?// Function.prototype doesn't have a prototype property
? ? ?fNOP.prototype = this.prototype ? ?}

? ?return fBound ?}}

1 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
JavaScript深入淺出
  • 參與學(xué)習(xí)       281098    人
  • 解答問題       1048    個(gè)

由淺入深學(xué)習(xí)JS語言特性,且解析JS常見誤區(qū),從入門到掌握

進(jìn)入課程

bind方法不是棄用了嗎?

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)