<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Comment Feed for Channel 9 - Understanding Function versus Global Scope - 10</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Series/Javascript-Fundamentals-Development-for-Absolute-Beginners/Understanding-Function-versus-Global-Scope-10/RSS"></atom:link>
	<image>
		<url>http://media.ch9.ms/ch9/3165/22692633-01b9-4bdf-9a6a-5c8993dc3165/10UnderstandingFunctionversusGlobalScope_220.jpg</url>
		<title>Channel 9 - Understanding Function versus Global Scope - 10</title>
		<link></link>
	</image>
	<description>One often misunderstood topic that leads to errors in programs is how JavaScript treats variables declared inside and outside of functions. This video explains the ramifications of variable scope at both the functional and global levels. For developers coming from other programming languages, it demonstrates how your familiarity with block scope will lead you to erroneous conclusions about JavaScript&#39;s functional and global scope. Also briefly discussed is the notion of hoisting in JavaScript. </description>
	<link></link>
	<language>en</language>
	<pubDate>Wed, 22 May 2013 12:17:10 GMT</pubDate>
	<lastBuildDate>Wed, 22 May 2013 12:17:10 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<item>
		<title>Re: Understanding Function versus Global Scope - 10</title>
		<description>
			<![CDATA[<p>You Say about the myScope variable that you defined outside the<br>anonymous function it's the same variable that you defined inside anonymous<br>function and the value of variable is temporary change.<br>but this is not true <br>because the two variable have the different memory location not the same<br>because in anonymous function you add the keyword var before the myScope<br>variable.<br>and if you want to be the two become the same memory location you need to<br>remove the keyword var in anonymous function.</p><p>posted by Mohammed_Oda</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/Javascript-Fundamentals-Development-for-Absolute-Beginners/Understanding-Function-versus-Global-Scope-10#c634802850274035664</link>
		<pubDate>Sat, 11 Aug 2012 12:30:27 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/Javascript-Fundamentals-Development-for-Absolute-Beginners/Understanding-Function-versus-Global-Scope-10#c634802850274035664</guid>
		<dc:creator>Mohammed_Oda</dc:creator>
	</item>
	<item>
		<title>Re: Understanding Function versus Global Scope - 10</title>
		<description>
			<![CDATA[<p>I would have expected in the 2nd alert box to see that myScope was changed to &quot;changed&quot;, but it remains &quot;global&quot;.</p><p><pre class="brush: js">myScope = &quot;global&quot;;

(function () {
    myScope = &quot;changed&quot;;
    var myScope = &quot;function&quot;;
    alert('inside the function, the scope is: ' &#43; myScope);
})();

alert('outside the function, the scope is: ' &#43; myScope);</pre></p><p>posted by asok14215</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/Javascript-Fundamentals-Development-for-Absolute-Beginners/Understanding-Function-versus-Global-Scope-10#c634822389909429540</link>
		<pubDate>Mon, 03 Sep 2012 03:16:30 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/Javascript-Fundamentals-Development-for-Absolute-Beginners/Understanding-Function-versus-Global-Scope-10#c634822389909429540</guid>
		<dc:creator>asok14215</dc:creator>
	</item>
	<item>
		<title>Re: Understanding Function versus Global Scope - 10</title>
		<description>
			<![CDATA[&#64;asok14215<br>Please listen to him &#64;7.20 to 7.40, he explain the reason for your output.<p>posted by tssutha</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/Javascript-Fundamentals-Development-for-Absolute-Beginners/Understanding-Function-versus-Global-Scope-10#c634833579173086243</link>
		<pubDate>Sun, 16 Sep 2012 02:05:17 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/Javascript-Fundamentals-Development-for-Absolute-Beginners/Understanding-Function-versus-Global-Scope-10#c634833579173086243</guid>
		<dc:creator>tssutha</dc:creator>
	</item>
	<item>
		<title>Re: Understanding Function versus Global Scope - 10</title>
		<description>
			<![CDATA[Bob, I am enjoying these videos and learning much from them.  Thank you for producing them&#33;<br><br>However, in this video I must say I was left somewhat confused.  That is, I thought there should have been more in-depth explanation for the various cases and why the results are what they are.<br><br>I too am confused by the results of the code posted by &#64;asok14215.  And while it MAY be true &#40;don&#39;t know&#41; that hoisting is responsible for the results &#40;as suggested by &#64;tssutha&#41;, I didn&#39;t get enough from this video to understand IF it&#39;s due to hoisting or WHY &#40;if it even is&#41;.  The example in the video &#64; 7&#58;20 &#40;ish&#41; does not seem to me to be the same thing &#64;asok14215 is doing.<br><br>Can you offer any insight&#63;<br><br>Thanks again.<p>posted by CindyS</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/Javascript-Fundamentals-Development-for-Absolute-Beginners/Understanding-Function-versus-Global-Scope-10#c634854132694943311</link>
		<pubDate>Tue, 09 Oct 2012 21:01:09 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/Javascript-Fundamentals-Development-for-Absolute-Beginners/Understanding-Function-versus-Global-Scope-10#c634854132694943311</guid>
		<dc:creator>CindyS</dc:creator>
	</item>
	<item>
		<title>Re: Understanding Function versus Global Scope - 10</title>
		<description>
			<![CDATA[<p>@<a href="/Series/Javascript-Fundamentals-Development-for-Absolute-Beginners/Understanding-Function-versus-Global-Scope-10#c634854132694943311">CindyS</a>: Hi Cindy ... check this out ...&nbsp;<a href="http://net.tutsplus.com/tutorials/javascript-ajax/quick-tip-javascript-hoisting-explained/">http&#58;&#47;&#47;net.tutsplus.com&#47;tutorials&#47;javascript-ajax&#47;quick-tip-javascript-hoisting-explained&#47;</a> ... I think they do a nice job explaining it. &nbsp;Also, did they explain it differently than I did? &nbsp;I'm sorry to add confusion to the topic!</p><p>posted by BobTabor</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/Javascript-Fundamentals-Development-for-Absolute-Beginners/Understanding-Function-versus-Global-Scope-10#c634854292259564222</link>
		<pubDate>Wed, 10 Oct 2012 01:27:05 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/Javascript-Fundamentals-Development-for-Absolute-Beginners/Understanding-Function-versus-Global-Scope-10#c634854292259564222</guid>
		<dc:creator>BobTabor</dc:creator>
	</item>
	<item>
		<title>Re: Understanding Function versus Global Scope - 10</title>
		<description>
			<![CDATA[Bob,<br>Thanks for the very prompt response and link - I think I understand the hoisting concept now.  You didn&#39;t add any confusion - I was already there... Don&#39;t know that nettuts explained it differently than you did, just a bit more thoroughly perhaps&#63;  As a side note, that site has a TON of information and appears to be an excellent resource &#40;that I will now have to figure out a way to devote some time to&#33;&#41;.<br><br>I THINK I now understand what is happening behind the scenes in asok14215&#39;s code sample...the declaration &#40;not the assignment&#41; portion of&#58;<br>  var myScope &#61; &#34;function&#34;&#59;<br>is hoisted to the beginning of the function block, then its value is set to &#39;changed&#39;, then its value is set to &#39;function&#39;, then the 1st alert&#40;&#41; is executed, thereby displaying &#39;function&#39; as the value.  After that, the function block ends so the second alert when executed displays the globally-scoped value for myScope, which is still &#39;global&#39;.<br><br>In any case, it seems that declaring multiple variables with the same name - even if JavaScript permits it - is not a good idea and not a &#39;best practice.&#39;<br><br>Looking forward to continuing through the tutorials, so thanks again&#33;<br><p>posted by CindyS</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/Javascript-Fundamentals-Development-for-Absolute-Beginners/Understanding-Function-versus-Global-Scope-10#c634854390180474773</link>
		<pubDate>Wed, 10 Oct 2012 04:10:18 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/Javascript-Fundamentals-Development-for-Absolute-Beginners/Understanding-Function-versus-Global-Scope-10#c634854390180474773</guid>
		<dc:creator>CindyS</dc:creator>
	</item>
	<item>
		<title>Re: Understanding Function versus Global Scope - 10</title>
		<description>
			<![CDATA[Just to clarify - I didn&#39;t mean to suggest that YOU were saying declaring variables with the same name IS a good idea...I was simply offering my opinion on the subject.<br><br>I guess I just don&#39;t see a good reason for doing that...perhaps there are reasons why you might have to &#40;that I just haven&#39;t come across yet&#41;.  Along the same lines, it seems to me it would be clearer and less risky to just declare the variables at the beginning of the block in which they are used, thereby eliminating hoisting issues altogether.<p>posted by CindyS</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/Javascript-Fundamentals-Development-for-Absolute-Beginners/Understanding-Function-versus-Global-Scope-10#c634854395708568247</link>
		<pubDate>Wed, 10 Oct 2012 04:19:30 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/Javascript-Fundamentals-Development-for-Absolute-Beginners/Understanding-Function-versus-Global-Scope-10#c634854395708568247</guid>
		<dc:creator>CindyS</dc:creator>
	</item>
	<item>
		<title>Re: Understanding Function versus Global Scope - 10</title>
		<description>
			<![CDATA[<p><span>Re-opening this closed thread ...</span></p><p>posted by BobTabor</p>]]>
		</description>
		<link>http://channel9.msdn.com/Series/Javascript-Fundamentals-Development-for-Absolute-Beginners/Understanding-Function-versus-Global-Scope-10#c634969825410986324</link>
		<pubDate>Wed, 20 Feb 2013 18:42:21 GMT</pubDate>
		<guid isPermaLink="true">http://channel9.msdn.com/Series/Javascript-Fundamentals-Development-for-Absolute-Beginners/Understanding-Function-versus-Global-Scope-10#c634969825410986324</guid>
		<dc:creator>BobTabor</dc:creator>
	</item>
</channel>
</rss>