PTT
Submit
Submit
選擇語言
正體中文
简体中文
PTT
Ajax
[問題] 增加prototype function
作者:
RichieRich
(Richie)
2021-01-06 17:01:20
小弟為了能讓 ie8可支持array新的function如map,filter...
if (!Array.prototype.forEach) {
Array.prototype.filter = function(callback/*, thisArg*/) {....
可是當我作in例舉的時候 會把這些function也例舉出來
例如
for(var key in [1,2,3])
{
console.log(key);
}
0,1,2,map,filter
是不是這樣自已加的function就不能用in這個東西?除非要自已過濾?
不然就無解?
謝謝
作者:
mrbigmouth
(大嘴先生)
2021-01-07 10:45:00
用Object.defineProperty給prototype加filter方法然後加上enumerable: false欸 ie8的defineProperty只能用在DOM上?
https://github.com/es-shims/es5-shim
參考一下
作者:
brianwu1201
(bunny29)
2021-01-07 11:18:00
https://developer.mozilla.org/en-US/docs/Web/Java
Script/Reference/Global_Objects/Object/hasOwnProperty關鍵字 hasOwnProperty 查一下
繼續閱讀
[問題] colab 的下拉式選單內容於 html 內不存在
art1
[教學] JavaScript 演算法:合併排序 Merge Sort
pply
[問題] get api一直回覆400 bad request(已解決)
jeffguoft
[問題] 如何偵測使用者正在看這網頁?
jami520
[問題] 請問為什麼存入資料庫的順序會亂掉?
jeffguoft
Fw: [閒聊] 愛好網頁程式開發者的群組
HwangTW
[問題] axios route的問題
Ericz7000
Fw: [請益] Ajax傳值到後端問題(已解決)
firetim
[問題] 請推薦新手用書
HwangTW
[問題] 如何用Chrome的開發者工具一步一步的解析js的執行步驟?
freeman371
Links
booklink
Contact Us: admin [ a t ] ucptt.com