Created
July 19, 2015 11:25
-
-
Save Bambina-zz/65b3e56f3e9835fe73bf to your computer and use it in GitHub Desktop.
js hoisting
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 global = "global"; | |
(function x(){ //即時実行形式なのでカッコ()が多いです。 | |
console.log(global); //=>undefined ローカル変数globalが定義されているが(var global;)、中身がない状態。 | |
var global = "local"; //文字列localが代入された。 | |
console.log(global); //=>local ローカル変数globalの中身がそのまま出力される。 | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment