這篇文章主要為大家展示了“JavaScript中every函數(shù)怎么用”,內(nèi)容簡(jiǎn)而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“JavaScript中every函數(shù)怎么用”這篇文章吧。
arr.every(callbackFn(currentValue[, index[, array]])[, thisArg])
Array.prototype.myEvery = function(callbackFn, thisArg) { if (typeof callbackFn !== 'function') throw ('callbackFn參數(shù)必須是函數(shù)'); let element = this, len = element && element.length || 0; if (!thisArg) thisArg = element; for(let index = 0; index < len; index++) { if (!callbackFn.call(thisArg, element[index], index, element)) return false; } return true; }
以上是“JavaScript中every函數(shù)怎么用”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!