我有功能A
,它定義了另一個函數B
。 B作爲argument
傳遞給另一功能C
至handle event
供以後使用。功能B need data
從function A
。是否有可能以這種方式傳遞數據?從外部函數傳遞數據在內部函數中供以後使用
function A(B){
var o = [1,2,3];
B = function() {
alert(this.blio); // data from A blio is undefined
};
B.blio = o; //bind data in property to B
$('selector').C({ result: B}); //handle event
}
當您嘗試時,是什麼行爲? –
在函數B中,this.blio是未定義的。 – TheChampp
調用「B()」的代碼是什麼? –