Created
June 11, 2010 07:30
-
-
Save mapiondev/434182 to your computer and use it in GitHub Desktop.
無名関数の即時実行
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var elm1 = "てすてす"; | |
// 無名関数の即時実行 | |
(function(){ | |
var elm2 = "テステス"; | |
alert("無名関数が実行されました"); | |
alert(elm1); // => てすてす | |
alert(elm2); // => テステス | |
})(); | |
alert(elm1); // => てすてす | |
// スコープが区切られるので参照できません! | |
alert(elm2); // エラー(ReferenceError) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment