2014-01-12 23 views

回答

3
var x = function(str) { 
    return x.something(str); 
}; 

x.something = function(str) { 
    console.log(str); 
}; 
1

函數是對象,所以你可以這樣做:

var x = function(y) { 
    console.log(y); 
} 
x.prop = function(){ return 'This works'; }; 

x('hi'); 
console.log(x.prop()); 
相關問題