<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: isset for javascript</title>
	<atom:link href="http://verens.com/archives/2005/07/25/isset-for-javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://verens.com/archives/2005/07/25/isset-for-javascript/</link>
	<description>php, linux, ajax, javascript, kae verens</description>
	<lastBuildDate>Fri, 05 Mar 2010 01:53:58 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: PHP funkcije v Javascript jeziku - isset &#124; .: TRSplet - internetne storitve .:</title>
		<link>http://verens.com/archives/2005/07/25/isset-for-javascript/comment-page-1/#comment-89635</link>
		<dc:creator>PHP funkcije v Javascript jeziku - isset &#124; .: TRSplet - internetne storitve .:</dc:creator>
		<pubDate>Mon, 28 Apr 2008 18:38:42 +0000</pubDate>
		<guid isPermaLink="false">http://verens.com/archives/2005/07/25/isset-for-javascript/#comment-89635</guid>
		<description>[...] Blog - isset for javascript [...]</description>
		<content:encoded><![CDATA[<p>[...] Blog &#8211; isset for javascript [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Judd</title>
		<link>http://verens.com/archives/2005/07/25/isset-for-javascript/comment-page-1/#comment-56188</link>
		<dc:creator>James Judd</dc:creator>
		<pubDate>Mon, 20 Aug 2007 18:04:41 +0000</pubDate>
		<guid isPermaLink="false">http://verens.com/archives/2005/07/25/isset-for-javascript/#comment-56188</guid>
		<description>You could try:

if(variablename.value == &quot;&quot;) {
        var variablename = &quot;whatever&quot;
}

Works for me.

- Juddling</description>
		<content:encoded><![CDATA[<p>You could try:</p>
<p>if(variablename.value == &#8220;&#8221;) {<br />
        var variablename = &#8220;whatever&#8221;<br />
}</p>
<p>Works for me.</p>
<p>- Juddling</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RussellReal</title>
		<link>http://verens.com/archives/2005/07/25/isset-for-javascript/comment-page-1/#comment-50241</link>
		<dc:creator>RussellReal</dc:creator>
		<pubDate>Thu, 21 Jun 2007 21:57:25 +0000</pubDate>
		<guid isPermaLink="false">http://verens.com/archives/2005/07/25/isset-for-javascript/#comment-50241</guid>
		<description>Ok, well for all of you that need this, set the variable you plan to use, such as:

string

in the head section just put var string;

then when you want to check the contents and see if it filled successfully,

do: if (string.length) { } because string.length will return 0 which is false, and will return a number greater then 1 (which is true) if the variable has any text whatsoever in it, and works the same for an array, but will return the number of array elements inside not letters. enjoy ;)</description>
		<content:encoded><![CDATA[<p>Ok, well for all of you that need this, set the variable you plan to use, such as:</p>
<p>string</p>
<p>in the head section just put var string;</p>
<p>then when you want to check the contents and see if it filled successfully,</p>
<p>do: if (string.length) { } because string.length will return 0 which is false, and will return a number greater then 1 (which is true) if the variable has any text whatsoever in it, and works the same for an array, but will return the number of array elements inside not letters. enjoy <img src='http://verens.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: caramba</title>
		<link>http://verens.com/archives/2005/07/25/isset-for-javascript/comment-page-1/#comment-44573</link>
		<dc:creator>caramba</dc:creator>
		<pubDate>Thu, 12 Apr 2007 19:03:42 +0000</pubDate>
		<guid isPermaLink="false">http://verens.com/archives/2005/07/25/isset-for-javascript/#comment-44573</guid>
		<description>vão arrumar alguma coisa pra fazer!</description>
		<content:encoded><![CDATA[<p>vão arrumar alguma coisa pra fazer!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kirk</title>
		<link>http://verens.com/archives/2005/07/25/isset-for-javascript/comment-page-1/#comment-43540</link>
		<dc:creator>Kirk</dc:creator>
		<pubDate>Wed, 28 Mar 2007 17:46:42 +0000</pubDate>
		<guid isPermaLink="false">http://verens.com/archives/2005/07/25/isset-for-javascript/#comment-43540</guid>
		<description>&#039;varname&#039; and &#039;arguments[0]&#039; are both local vars to isset(), not the test(). var2 is the only one that fails because it is not defined within the scope of isset() (includes global scope). I don&#039;t think there&#039;s any method that would allow you to access the local vars of the test(). The reason I put argument[0] in the list, is so that no one has misconception of isset() working for local vars using arguments[0]. it will always be true in any function if an argument is set. Basically, the main use of isset(), to check what parameters were entered into a function test(), appears to be impossible to achieve in js as isset() has no access to test()&#039;s local variable (this includes test()&#039;s arguments)</description>
		<content:encoded><![CDATA[<p>&#8216;varname&#8217; and &#8216;arguments[0]&#8216; are both local vars to isset(), not the test(). var2 is the only one that fails because it is not defined within the scope of isset() (includes global scope). I don&#8217;t think there&#8217;s any method that would allow you to access the local vars of the test(). The reason I put argument[0] in the list, is so that no one has misconception of isset() working for local vars using arguments[0]. it will always be true in any function if an argument is set. Basically, the main use of isset(), to check what parameters were entered into a function test(), appears to be impossible to achieve in js as isset() has no access to test()&#8217;s local variable (this includes test()&#8217;s arguments)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kae Verens</title>
		<link>http://verens.com/archives/2005/07/25/isset-for-javascript/comment-page-1/#comment-43506</link>
		<dc:creator>Kae Verens</dc:creator>
		<pubDate>Wed, 28 Mar 2007 08:05:50 +0000</pubDate>
		<guid isPermaLink="false">http://verens.com/archives/2005/07/25/isset-for-javascript/#comment-43506</guid>
		<description>Kirk, the local tests appear to be failing. in the first case (isset(&#039;var2&#039;)), false is returned, and in the second case (isset(&#039;arguments[0]&#039;)), that will always return true, as arguments[0] is the string &quot;arguments[0]&quot; (the first argument of the function isset()).

Also, isset(&#039;varname&#039;) will always return true, as it is set in the isset() function, and so is not properly tested (what if it was set in the test() function?).

Or am I missing something?</description>
		<content:encoded><![CDATA[<p>Kirk, the local tests appear to be failing. in the first case (isset(&#8216;var2&#8242;)), false is returned, and in the second case (isset(&#8216;arguments[0]&#8216;)), that will always return true, as arguments[0] is the string &#8220;arguments[0]&#8221; (the first argument of the function isset()).</p>
<p>Also, isset(&#8216;varname&#8217;) will always return true, as it is set in the isset() function, and so is not properly tested (what if it was set in the test() function?).</p>
<p>Or am I missing something?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kirk</title>
		<link>http://verens.com/archives/2005/07/25/isset-for-javascript/comment-page-1/#comment-43502</link>
		<dc:creator>Kirk</dc:creator>
		<pubDate>Wed, 28 Mar 2007 07:34:48 +0000</pubDate>
		<guid isPermaLink="false">http://verens.com/archives/2005/07/25/isset-for-javascript/#comment-43502</guid>
		<description>&lt;strong&gt;Is it possible to write an isset() function that can access the local scope of a function??&lt;/strong&gt;



function isset(varname) { return eval(&#039;typeof(&#039; + varname + &#039;) != &quot;undefined&quot;&#039;); }

var1 = &#039;test&#039;; // global var

function test()
{
	var var2 = &#039;test&#039;; // local var
	alert(&#039;var1 isset() = &#039; + isset(&#039;var1&#039;)); // true; global var
	alert(&#039;var2 isset() = &#039; + isset(&#039;var2&#039;)); // false; local var
	alert(&#039;varname isset() = &#039; + isset(&#039;varname&#039;)); // true; local var to isset()
	alert(&#039;arguments[0] isset() = &#039; + isset(&#039;arguments[0]&#039;)); // true; local var to isset()
}

test();



Assumptions based on tests:

&lt;strong&gt;typeof(window[varname]) != &#039;undefined&#039;);&lt;/strong&gt; can see only global scope, and gives no error
&lt;strong&gt;typeof(eval(varname) != &#039;undefined&#039;);&lt;/strong&gt; can see local scope of isset(), but gives an error if not defined
&lt;strong&gt;eval(&#039;typeof(&#039; + varname + &#039;) != &quot;undefined&quot;&#039;);&lt;/strong&gt; can see local scope of isset(), and gives no errors


All of these scripts use one of the two, which can only access vars within the scope of the function.
This includes local vars in isset() ie. varname, arguments[0] and global vars.

This would be useful for testing argument input in functions. 
Yes, I can write out  if(typeof(var1) != &#039;undefined&#039;)  each time but I&#039;m lazy.
I&#039;m also a PHP programmer and would like to use one set of terminology.</description>
		<content:encoded><![CDATA[<p><strong>Is it possible to write an isset() function that can access the local scope of a function??</strong></p>
<p>function isset(varname) { return eval(&#8216;typeof(&#8216; + varname + &#8216;) != &#8220;undefined&#8221;&#8216;); }</p>
<p>var1 = &#8216;test&#8217;; // global var</p>
<p>function test()<br />
{<br />
	var var2 = &#8216;test&#8217;; // local var<br />
	alert(&#8216;var1 isset() = &#8216; + isset(&#8216;var1&#8242;)); // true; global var<br />
	alert(&#8216;var2 isset() = &#8216; + isset(&#8216;var2&#8242;)); // false; local var<br />
	alert(&#8216;varname isset() = &#8216; + isset(&#8216;varname&#8217;)); // true; local var to isset()<br />
	alert(&#8216;arguments[0] isset() = &#8216; + isset(&#8216;arguments[0]&#8216;)); // true; local var to isset()<br />
}</p>
<p>test();</p>
<p>Assumptions based on tests:</p>
<p><strong>typeof(window[varname]) != &#8216;undefined&#8217;);</strong> can see only global scope, and gives no error<br />
<strong>typeof(eval(varname) != &#8216;undefined&#8217;);</strong> can see local scope of isset(), but gives an error if not defined<br />
<strong>eval(&#8216;typeof(&#8216; + varname + &#8216;) != &#8220;undefined&#8221;&#8216;);</strong> can see local scope of isset(), and gives no errors</p>
<p>All of these scripts use one of the two, which can only access vars within the scope of the function.<br />
This includes local vars in isset() ie. varname, arguments[0] and global vars.</p>
<p>This would be useful for testing argument input in functions.<br />
Yes, I can write out  if(typeof(var1) != &#8216;undefined&#8217;)  each time but I&#8217;m lazy.<br />
I&#8217;m also a PHP programmer and would like to use one set of terminology.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kae Verens</title>
		<link>http://verens.com/archives/2005/07/25/isset-for-javascript/comment-page-1/#comment-38218</link>
		<dc:creator>Kae Verens</dc:creator>
		<pubDate>Sat, 03 Feb 2007 05:49:42 +0000</pubDate>
		<guid isPermaLink="false">http://verens.com/archives/2005/07/25/isset-for-javascript/#comment-38218</guid>
		<description>DieHard, I don&#039;t think yours would work with a variable name such as &quot;this.var1&quot;</description>
		<content:encoded><![CDATA[<p>DieHard, I don&#8217;t think yours would work with a variable name such as &#8220;this.var1&#8243;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DieHard</title>
		<link>http://verens.com/archives/2005/07/25/isset-for-javascript/comment-page-1/#comment-38184</link>
		<dc:creator>DieHard</dc:creator>
		<pubDate>Sat, 03 Feb 2007 00:20:01 +0000</pubDate>
		<guid isPermaLink="false">http://verens.com/archives/2005/07/25/isset-for-javascript/#comment-38184</guid>
		<description>I think correct answer is - 


function isset(variable_name)
{
	try
	{
		if (typeof(eval(variable_name)) != &#039;undefined&#039;)
			if (eval(variable_name) != null)
				return true;
	} catch(e) { }
	
	return false;
}


variable_name is a string param</description>
		<content:encoded><![CDATA[<p>I think correct answer is &#8211; </p>
<p>function isset(variable_name)<br />
{<br />
	try<br />
	{<br />
		if (typeof(eval(variable_name)) != &#8216;undefined&#8217;)<br />
			if (eval(variable_name) != null)<br />
				return true;<br />
	} catch(e) { }</p>
<p>	return false;<br />
}</p>
<p>variable_name is a string param</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://verens.com/archives/2005/07/25/isset-for-javascript/comment-page-1/#comment-22750</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Fri, 08 Sep 2006 21:01:05 +0000</pubDate>
		<guid isPermaLink="false">http://verens.com/archives/2005/07/25/isset-for-javascript/#comment-22750</guid>
		<description>thanks for the 
     if(undefined===window.variablename){
     window.variablename = [];
     }

that was exactly what i needed</description>
		<content:encoded><![CDATA[<p>thanks for the<br />
     if(undefined===window.variablename){<br />
     window.variablename = [];<br />
     }</p>
<p>that was exactly what i needed</p>
]]></content:encoded>
	</item>
</channel>
</rss>
