{"id":245,"date":"2012-09-05T20:53:30","date_gmt":"2012-09-05T11:53:30","guid":{"rendered":"http:\/\/www.freesens.com\/x\/?p=245"},"modified":"2012-09-05T20:57:55","modified_gmt":"2012-09-05T11:57:55","slug":"javascript-hoisting","status":"publish","type":"post","link":"http:\/\/www.freesens.com\/x\/?p=245","title":{"rendered":"JavaScript Hoisting."},"content":{"rendered":"<p>\ucc38\uace0 URL :\u00a0<a href=\"http:\/\/www.adequatelygood.com\/2010\/2\/JavaScript-Scoping-and-Hoisting\">http:\/\/www.adequatelygood.com\/2010\/2\/JavaScript-Scoping-and-Hoisting<\/a><\/p>\n<p>\uc544\ub798 \uc0d8\ud50c\ucf54\ub4dc\uc640 \uac19\uc774 \uc791\uc131\ud55c \uacbd\uc6b0 \uc758\ub3c4\ud558\uc9c0 \uc54a\uac8c \uc5c9\ub6b1\ud55c \uacb0\uacfc\ub97c \ucd9c\ub825\ud560 \uc218\ub3c4 \uc788\uc73c\ub2c8&#8230;\uc8fc\uc758\ud574\uc57c \ud568.<\/p>\n<table border=\"0\" cellspacing=\"1\" cellpadding=\"5\" bgcolor=\"#f7f7f7\">\n<tbody>\n<tr>\n<td>\n<pre>strVal = \"global\";\r\nfunction myFunc() {\r\n    alert(strVal);\r\n    <span style=\"color: #ff0000;\">var strVal = \"local\";<\/span>\r\n    alert(strVal);\r\n}\r\nmyFunc();<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\uc704\uc758 \ucf54\ub4dc\uc758 \uc2e4\ud589\uacb0\uacfc\ub97c \ub2e8\uc21c\ud788 \uc608\uce21\ud574\ubcf4\uba74 \ud654\uba74\uc0c1\uc5d0 \uc544\ub798\uc640 \uac19\uc774 \ucd9c\ub825\ub420 \uac83\uc774\ub77c \uc0dd\uac01\ud560 \uc218 \uc788\ub2e4.<\/p>\n<table border=\"0\" cellspacing=\"1\" cellpadding=\"5\" bgcolor=\"#f7f7f7\">\n<tbody>\n<tr>\n<td>global<br \/>\nlocal<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\ud558\uc9c0\ub9cc \uc2e4\uc81c \uacb0\uacfc\ub294 \uc544\ub798\ucc98\ub7fc \uc2e4\ud589\ub41c\ub2e4.<\/p>\n<table border=\"0\" cellspacing=\"1\" cellpadding=\"5\" bgcolor=\"#f7f7f7\">\n<tbody>\n<tr>\n<td>undefined<br \/>\nlocal<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\uc774\ub294 \uc790\ubc14\uc2a4\ud06c\ub9bd\ud2b8\uc5d0\uc11c var\ub85c \ubcc0\uc218\ub97c \uba85\uc2dc\uc801\uc73c\ub85c \uc120\uc5b8\ud558\uae30 \uc774\uc804\uc5d0\ub3c4 \ud574\ub2f9 \ubcc0\uc218\uba85\uc744 \uc774\uc6a9\ud560 \uc218 \uc788\ub3c4\ub85d \uc720\uc5f0\ud558\uac8c, \ub300\ucc98\ud558\uae30 \ub54c\ubb38\uc73c\ub85c&#8230;&#8230; myFunc() \ud568\uc218 \uc548\uc5d0\uc11c var strVal\uc744 \uc120\uc5b8\ud558\uae30 \uc774\uc804\uc5d0 alert()\uc73c\ub85c \ud574\ub2f9 \ubcc0\uc218\ub97c \ud638\ucd9c\ud558\ub354\ub77c\ub3c4, \uc804\uc5ed\ubcc0\uc218\ub97c \uc0ac\uc6a9\ud558\ub294 \uac83\uc774 \uc544\ub2c8\ub77c, var strVal\uac00 \uc6b0\uc120\uc801\uc73c\ub85c myFunc()\uc548\uc5d0\uc11c \uc218\ud589\ub418\uae30 \ub54c\ubb38\uc5d0&#8230;&#8230;..\uc704\uc758 \uc0d8\ud50c\ucf54\ub4dc\ub294 \uc2e4\uc81c\ub85c \uc544\ub798 \ucf54\ub4dc\uc640 \uac19\uc774 myFunc() \uc548\uc758 var\uc744 \uc774\uc6a9\ud55c \uc120\uc5b8\ubd80\uac00 \uba3c\uc800 \uc218\ud589\ub41c\ub2e4.<\/p>\n<table border=\"0\" cellspacing=\"1\" cellpadding=\"5\" bgcolor=\"#f7f7f7\">\n<tbody>\n<tr>\n<td>\n<pre>strVal = \"global\";\r\nfunction myFunc() {\r\n    <span style=\"color: #ff0000;\">var strVal;<\/span>\r\n    alert(strVal);\r\n    strVal = \"local\";\r\n    alert(strVal);\r\n}\r\nmyFunc();<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>JavaScript\uc5d0\uc11c var\ub85c \ubcc0\uc218\ub97c \uc120\uc5b8\ud558\uace0 \uac12\uc744 \ud560\ub2f9\ud558\uae30 \uc804\uae4c\uc9c0\ub294 \uae30\ubcf8\uac12\uc73c\ub85c &#8220;undefined&#8221;\uac00 \u00a0\ub418\uae30 \ub54c\ubb38\uc5d0 \uccab\ubc88\uc9f8 alert\uc5d0\uc11c\ub294 undefined\ub85c \ucd9c\ub825\ub418\uace0, \ub450\ubc88\uc9f8 alert\uc5d0\uc11c\ub294 \ud560\ub2f9\ub41c \ubb38\uc790\uc5f4\uc774 \ucd9c\ub825\ub41c\ub2e4.<\/p>\n<p>\uac04\ub2e8\ud55c \ub0b4\uc6a9\uc774\uc9c0\ub9cc \ubb34\uc2ec\ucf54 \uc0ac\uc6a9\ud558\ub2e4 \ubcf4\uba74&#8230;..\uc5c9\ub6b1\ud55c \uacb0\uacfc\uac00 \ub098\uc640\uc11c \uc0bd\uc9c8\ud560 \uc218 \uc788\uc73c\ub2c8, \uc660\ub9cc\ud558\ub9cc \ubcc0\uc218 \uc120\uc5b8\uc740 \uc0c1\ub2e8\uc5d0\uc11c \ud55c\ubc88\uc5d0 \ubbf8\ub9ac \uc815\uc758\ud558\ub294\uac8c \uc88b\uc74c.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\ucc38\uace0 URL :\u00a0http:\/\/www.adequatelygood.com\/2010\/2\/JavaScript-Scoping-and-Hoisting \uc544\ub798 \uc0d8\ud50c\ucf54\ub4dc\uc640 \uac19\uc774 \uc791\uc131\ud55c \uacbd\uc6b0 \uc758\ub3c4\ud558\uc9c0 \uc54a\uac8c \uc5c9\ub6b1\ud55c \uacb0\uacfc\ub97c \ucd9c\ub825\ud560 \uc218\ub3c4 \uc788\uc73c\ub2c8&#8230;\uc8fc\uc758\ud574\uc57c \ud568. strVal = &#8220;global&#8221;; function myFunc() { alert(strVal); var strVal = &#8220;local&#8221;; alert(strVal); } myFunc(); \uc704\uc758 \ucf54\ub4dc\uc758 \uc2e4\ud589\uacb0\uacfc\ub97c \ub2e8\uc21c\ud788 \uc608\uce21\ud574\ubcf4\uba74 \ud654\uba74\uc0c1\uc5d0 \uc544\ub798\uc640 \uac19\uc774 \ucd9c\ub825\ub420 \uac83\uc774\ub77c \uc0dd\uac01\ud560 \uc218 \uc788\ub2e4. global local \ud558\uc9c0\ub9cc \uc2e4\uc81c \uacb0\uacfc\ub294 \uc544\ub798\ucc98\ub7fc \uc2e4\ud589\ub41c\ub2e4. undefined local \uc774\ub294 \uc790\ubc14\uc2a4\ud06c\ub9bd\ud2b8\uc5d0\uc11c var\ub85c &hellip; <a href=\"http:\/\/www.freesens.com\/x\/?p=245\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">JavaScript Hoisting.<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-245","post","type-post","status-publish","format-standard","hentry","category-javascript"],"_links":{"self":[{"href":"http:\/\/www.freesens.com\/x\/index.php?rest_route=\/wp\/v2\/posts\/245","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.freesens.com\/x\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.freesens.com\/x\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.freesens.com\/x\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.freesens.com\/x\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=245"}],"version-history":[{"count":4,"href":"http:\/\/www.freesens.com\/x\/index.php?rest_route=\/wp\/v2\/posts\/245\/revisions"}],"predecessor-version":[{"id":249,"href":"http:\/\/www.freesens.com\/x\/index.php?rest_route=\/wp\/v2\/posts\/245\/revisions\/249"}],"wp:attachment":[{"href":"http:\/\/www.freesens.com\/x\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=245"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.freesens.com\/x\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=245"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.freesens.com\/x\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}