Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > Software > How to know if a variable is null

Reply
Thread Tools

How to know if a variable is null

 
 
peace2007 peace2007 is offline
Junior Member
Join Date: Sep 2007
Posts: 7
 
      09-29-2007
Hi,

I try to check if a variable is null via following code but I don't get an expected result:
Code:
 var askedUser = re.responseText;
		    askedUser = askedUser.substr(0, askedUser.indexOf('&',0));
			if(askedUser != null  && askedUser != " ")
			{	do something}
the if() returns true whether askedUser == "" or askedUser = "a value"!
Could anyone guide me please?
 
Reply With Quote
 
 
 
 
hamedvahedi hamedvahedi is offline
Junior Member
Join Date: Sep 2007
Location: Iran
Posts: 10
 
      09-30-2007
Change your code to this:
if(askedUser != NULL && askedUser != "")

Attention: NULL and ""

www.hamedvahedi.com
 

Last edited by hamedvahedi; 09-30-2007 at 05:25 AM..
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
"Variable variable name" or "variable lvalue" mfglinux Python 11 09-12-2007 03:08 AM
"stringObj == null" vs "stringObj.equals(null)", for null check?? qazmlp1209@rediffmail.com Java 5 03-29-2006 10:37 PM
How do I scope a variable if the variable name contains a variable? David Filmer Perl Misc 19 05-21-2004 03:55 PM
I know, I know, I don't know Andries Perl Misc 3 04-23-2004 02:17 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57