我現在知道這個工程:在函數內部編寫javascript函數並且不在主函數中使用'new'是否好?
function outerfunction(arg1, arg2, arg3) {
var others;
//Some code
innerFunction();
function innerFunction() {
//do some stuff
//I have access to the args and vars of the outerFunction also I can limit the scope of vars in the innerFunction..!
}
//Also
$.ajax({
success : secondInnerFunction;
});
function secondInnerFunction() {
// Has all the same benefits!
}
}
outerFunction();
所以,我不上outerFunction做一個「新」,但我把它作爲一個對象!這在語義上有多正確?
感謝所有的答案,他們都是有價值的,我和幫助我理解這個概念很好,但系統不允許接受多個答案! :) – NikhilWanpal 2011-04-18 09:15:33