Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 12-08-2005, 03:02 AM   #1
Zester
Confirmed User
 
Zester's Avatar
 
Industry Role:
Join Date: Jul 2003
Posts: 5,344
Javascript: How do I check if a var is null or hasn't been set??

sounds simple doesn't it? this is fucking driving crazy

lets say "myvar" was never mentioned in the code anywhere.
the following gives an error message "myvar is undefined" which I want to avoid:

Code:
if ( myvar = =  undefined )
{
   // do nothing
}
I also tried:
Code:
if ( myvar = =  null )
if ( myvar = =   0 )
if ( myvar = =   "" )
if ( myvar = =   '' )
of course I don't use spaces between the two "=" but that's just for displaying
__________________
* Mainstream ? $65 per sale
* new male contraception
Zester is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-08-2005, 03:53 AM   #2
J.P.
Confirmed User
 
Join Date: Jun 2004
Posts: 689
try this:
Code:
if (typeof myvar = = "undefined") {
   // do something - or nothing :)
}
this should solve your problem...

of course, drop the space between = and =
__________________
Webmasters! Looking for new affiliate programs to promote?
Affiliate Program Search <-- Search for programs with FHGs, RSS feed, specific niche sponsors, ...

Last edited by J.P.; 12-08-2005 at 03:56 AM..
J.P. is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-08-2005, 06:09 AM   #3
emthree
Dialer Kingpin
 
Join Date: Jun 2003
Location: New York
Posts: 10,816
You must nul your var
__________________

Sell Patches & Pills
emthree is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-08-2005, 09:55 AM   #4
Zester
Confirmed User
 
Zester's Avatar
 
Industry Role:
Join Date: Jul 2003
Posts: 5,344
Quote:
Originally Posted by J.P.
try this:
Code:
if (typeof myvar = = "undefined") {
   // do something - or nothing :)
}
this should solve your problem...

of course, drop the space between = and =
thanks mate
__________________
* Mainstream ? $65 per sale
* new male contraception
Zester is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.