function createFunctionWithProperty(property) {
functionWithProperty.property = property;
return functionWithProperty;
function functionWithProperty() {
}
}
var a = createFunctionWithProperty(123);
var b = createFunctionWithProperty(321);
alert(a.property + " : " + b.property); // 123 : 321
したがって、私が知る限り、createFunctionWithProperty
とfunctionWithProperty
はJavaScript コードが実行される前に巻き上げられ、解析され、存在する関数宣言です。ただし、ある時点で、createFunctionWithProperty
関数を呼び出している間functionWithProperty
、クロージャーになりfunctionWithProperty
ます。これは、インスタンスごとに異なる独自のプロパティと変数を持つ関数の非常に特定のインスタンスです。それはすべて理論上ですが、この場合、物事がどのように機能するかわかりません。いつ、どのように正確functionWithProperty
に閉鎖になるかについて、詳細な内訳を誰かが教えてくれますか? ありがとうございました。