[英]What to use - Passing context or call/apply?
在javascript中,如果我必須在不同的上下文中調用一個函數,那么調用它的首選方法是什么。 為什么?
1) this
作為參數傳遞如下:
callthisfunction(arg1, arg2, this);
function callthisfunction(arg1, arg2, context) {}
要么
2)使用如下給出的電話/申請:
callthisfunction.call(this, arg1, arg2);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.