Web appOpen in Telegram
JJavaScript/Node.js 台灣
JavaScript/Node.js 台灣
@JavaScriptTw · group · Tech · indexed since 2026-07-05 archive for February 2018
1 999members−15 in a week
4writing in 30 days
15messages in 30 days
103 295messages in the index

Messages from February 2018

‹ February 2018 ›×
フ
我的 function call 是這樣 s.getThreads(epstr).map(db.download)
  1. W
    你其他的也是用類似的方式嗎? 你這個感覺像是 map 內呼叫 download 的 this 跑掉了
Whole thread · 1 reply →
フ
有看到 download(member function) 內的是有值的 (thread) 結果 this 卻不見了wwwwww
フ
但沒有用 apply / bind 來作 為什麼直接 call db.download 會讓 this 消失
W
this 是要看被誰呼叫,你放在 map 裡面就會跑掉了 你可以用 bind 或是直接用 arrow function 綁定 this
  1. W
    你上面那種做法是用 map 去呼叫 db.download,後面的話算是 db 自己呼叫 download
Whole thread · 1 reply →
F
map() 內的 context 在 map((thread) => { return db.download(thread); } 和 map(db.download) 下會不同
W
兩種呼叫的方式不同所以 this 會不同,你如果用 bind 的方式算是主動去綁定
フ
嗯嗯 感謝,之前看有文章推崇直接把 function 放進去 這種有 this 不算純函數不行這樣玩 😂
F
全用 arrow function 吧
W
如果用 function program 的方式我都是用無狀態並且沒 this 的作法
Whole thread · 1 reply →
フ
嗯嗯,剛剛沒意識到是 map(func) 的寫法有限制,一直看 class Database

An open public feed from the search index ChatCrawler — “Google for public Telegram”; refreshed as the venue is crawled. Times are UTC.

Public content only, official Telegram API. About · FAQ · What we do not do · Remove a page · Catalog · Search · How we count