<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.1" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: PHP-style $GLOBALS in Javascript?</title>
	<link>http://www.phpied.com/php-style-globals-in-javascript/</link>
	<description>Stoyan's blog about (x)html, ajax, bookmarklets, browsers, css, firebug, javascript, json, mdb2, mysql, pear, performance, php, phpbb, tools, yslow, yui, writing, music,... life and everything.</description>
	<pubDate>Tue, 13 May 2008 03:00:18 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.1</generator>

	<item>
		<title>by: Stoyan</title>
		<link>http://www.phpied.com/php-style-globals-in-javascript/#comment-64084</link>
		<pubDate>Tue, 18 Mar 2008 00:39:34 +0000</pubDate>
		<guid>http://www.phpied.com/php-style-globals-in-javascript/#comment-64084</guid>
					<description>Hi Marco,

I used the dollar sign just for the sake of the PHP analogy, and a little bit as a joke in the spirit of &quot;let's make JS like our other favorite language&quot; (looking at you, prototype.js). 

Using a namespace and a GLOBALS property is definitely a good way to do the same.</description>
		<content:encoded><![CDATA[<p>Hi Marco,</p>
<p>I used the dollar sign just for the sake of the PHP analogy, and a little bit as a joke in the spirit of "let's make JS like our other favorite language" (looking at you, prototype.js). </p>
<p>Using a namespace and a GLOBALS property is definitely a good way to do the same.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Marco</title>
		<link>http://www.phpied.com/php-style-globals-in-javascript/#comment-64055</link>
		<pubDate>Thu, 13 Mar 2008 21:45:45 +0000</pubDate>
		<guid>http://www.phpied.com/php-style-globals-in-javascript/#comment-64055</guid>
					<description>Interesting idea Stoyan!

Just out of curiosity though: why use a dollar sign? Just because it's more PHP-ish or is there another reason?

Also: In a YUI context you may want to use YAHOO.GLOBALS maybe? :)</description>
		<content:encoded><![CDATA[<p>Interesting idea Stoyan!</p>
<p>Just out of curiosity though: why use a dollar sign? Just because it's more PHP-ish or is there another reason?</p>
<p>Also: In a YUI context you may want to use YAHOO.GLOBALS maybe? <img src='http://www.phpied.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Stoyan Stefanov&#8217;s Blog: PHP-style $GLOBALS in Javascript? &#124; Cole Design Studios</title>
		<link>http://www.phpied.com/php-style-globals-in-javascript/#comment-64053</link>
		<pubDate>Thu, 13 Mar 2008 06:15:27 +0000</pubDate>
		<guid>http://www.phpied.com/php-style-globals-in-javascript/#comment-64053</guid>
					<description>[...] In a new post to his blog today, Stoyan Stefanov has a proposal to being something PHP users are very used to - superglobals - over to Javascript.   Javascript has implied globals. When you skip the var in var a = 1; and go a = 1;, then a becomes a global variable. Some consider this an error in the language. [&amp;#8230;] In PHP on the other hand, variables are local. [&amp;#8230;] So how about this: adopt the $GLOBALS convention in your JavaScripts? [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] In a new post to his blog today, Stoyan Stefanov has a proposal to being something PHP users are very used to - superglobals - over to Javascript.   Javascript has implied globals. When you skip the var in var a = 1; and go a = 1;, then a becomes a global variable. Some consider this an error in the language. [&#8230;] In PHP on the other hand, variables are local. [&#8230;] So how about this: adopt the $GLOBALS convention in your JavaScripts? [&#8230;]
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Stoyan Stefanov&#8217;s Blog: PHP-style $GLOBALS in Javascript? &#124; Cole Design Studios</title>
		<link>http://www.phpied.com/php-style-globals-in-javascript/#comment-64052</link>
		<pubDate>Thu, 13 Mar 2008 06:15:27 +0000</pubDate>
		<guid>http://www.phpied.com/php-style-globals-in-javascript/#comment-64052</guid>
					<description>[...] In a new post to his blog today, Stoyan Stefanov has a proposal to being something PHP users are very used to - superglobals - over to Javascript.   Javascript has implied globals. When you skip the var in var a = 1; and go a = 1;, then a becomes a global variable. Some consider this an error in the language. [&amp;#8230;] In PHP on the other hand, variables are local. [&amp;#8230;] So how about this: adopt the $GLOBALS convention in your JavaScripts? [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] In a new post to his blog today, Stoyan Stefanov has a proposal to being something PHP users are very used to - superglobals - over to Javascript.   Javascript has implied globals. When you skip the var in var a = 1; and go a = 1;, then a becomes a global variable. Some consider this an error in the language. [&#8230;] In PHP on the other hand, variables are local. [&#8230;] So how about this: adopt the $GLOBALS convention in your JavaScripts? [&#8230;]
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Sean Coates</title>
		<link>http://www.phpied.com/php-style-globals-in-javascript/#comment-64047</link>
		<pubDate>Wed, 12 Mar 2008 14:40:36 +0000</pubDate>
		<guid>http://www.phpied.com/php-style-globals-in-javascript/#comment-64047</guid>
					<description>They aren't really globals in JavaScript. The scope actually comes from the parent. Undefined variables appear to be global, that's true.

Scoping is really &quot;weird&quot; in JS if you've never worked in another language that does closures. See:
http://en.wikipedia.org/wiki/Closure_(computer_science)

Not saying you're wrong, of course, but thinking about JavaScript scopes the same way you think about PHP scopes is likely to lead to maintenance/development trouble down the road (-:

S</description>
		<content:encoded><![CDATA[<p>They aren't really globals in JavaScript. The scope actually comes from the parent. Undefined variables appear to be global, that's true.</p>
<p>Scoping is really "weird" in JS if you've never worked in another language that does closures. See:<br />
<a href='http://en.wikipedia.org/wiki/Closure_' rel='nofollow'>http://en.wikipedia.org/wiki/Closure_</a>(computer_science)</p>
<p>Not saying you're wrong, of course, but thinking about JavaScript scopes the same way you think about PHP scopes is likely to lead to maintenance/development trouble down the road (-:</p>
<p>S
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Stoyan Stefanov&#8217;s Blog: PHP-style $GLOBALS in Javascript? &#124; Development Blog With Code Updates : Developercast.com</title>
		<link>http://www.phpied.com/php-style-globals-in-javascript/#comment-64044</link>
		<pubDate>Wed, 12 Mar 2008 12:00:43 +0000</pubDate>
		<guid>http://www.phpied.com/php-style-globals-in-javascript/#comment-64044</guid>
					<description>[...] In a new post to his blog today, Stoyan Stefanov has a proposal to being something PHP users are very used to - superglobals - over to Javascript.   Javascript has implied globals. When you skip the var in var a = 1; and go a = 1;, then a becomes a global variable. Some consider this an error in the language. [&amp;#8230;] In PHP on the other hand, variables are local. [&amp;#8230;] So how about this: adopt the $GLOBALS convention in your JavaScripts? [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] In a new post to his blog today, Stoyan Stefanov has a proposal to being something PHP users are very used to - superglobals - over to Javascript.   Javascript has implied globals. When you skip the var in var a = 1; and go a = 1;, then a becomes a global variable. Some consider this an error in the language. [&#8230;] In PHP on the other hand, variables are local. [&#8230;] So how about this: adopt the $GLOBALS convention in your JavaScripts? [&#8230;]
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: PHPDeveloper.org</title>
		<link>http://www.phpied.com/php-style-globals-in-javascript/#comment-64043</link>
		<pubDate>Wed, 12 Mar 2008 11:56:18 +0000</pubDate>
		<guid>http://www.phpied.com/php-style-globals-in-javascript/#comment-64043</guid>
					<description>&lt;strong&gt;Stoyan Stefanov's Blog: PHP-style $GLOBALS in Javascript?...&lt;/strong&gt;


In a new post to his blog today, Stoyan Stefanov has ......</description>
		<content:encoded><![CDATA[<p><strong>Stoyan Stefanov's Blog: PHP-style $GLOBALS in Javascript?&#8230;</strong></p>
<p>In a new post to his blog today, Stoyan Stefanov has &#8230;&#8230;
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Stoyan</title>
		<link>http://www.phpied.com/php-style-globals-in-javascript/#comment-64009</link>
		<pubDate>Mon, 10 Mar 2008 17:33:52 +0000</pubDate>
		<guid>http://www.phpied.com/php-style-globals-in-javascript/#comment-64009</guid>
					<description>Thanks Steve! Worst of all, &lt;code&gt;&amp;#60;input id=&quot;tmp&quot; /&amp;#62;&lt;/code&gt; declares a global var &lt;code&gt;tmp&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Thanks Steve! Worst of all, <code>&lt;input id="tmp" /&gt;</code> declares a global var <code>tmp</code>
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Steve</title>
		<link>http://www.phpied.com/php-style-globals-in-javascript/#comment-64008</link>
		<pubDate>Mon, 10 Mar 2008 15:17:46 +0000</pubDate>
		<guid>http://www.phpied.com/php-style-globals-in-javascript/#comment-64008</guid>
					<description>Its actually a nice idea, I quite like it.

What I really do like though, is that the stuff you want to be global, isn't mixed in with all the clutter that the browser (especially IE) wants to be global.  e.g. if you run your globs code on a blank window in IE, you'll get a bunch of objects and properties before adding a single variable.</description>
		<content:encoded><![CDATA[<p>Its actually a nice idea, I quite like it.</p>
<p>What I really do like though, is that the stuff you want to be global, isn't mixed in with all the clutter that the browser (especially IE) wants to be global.  e.g. if you run your globs code on a blank window in IE, you'll get a bunch of objects and properties before adding a single variable.
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
