![]() |
![]() |
![]() |
||||
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. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
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 } Code:
if ( myvar = = null ) if ( myvar = = 0 ) if ( myvar = = "" ) if ( myvar = = '' ) |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Join Date: Jun 2004
Posts: 689
|
try this:
Code:
if (typeof myvar = = "undefined") { // do something - or nothing :) } 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, ... |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Dialer Kingpin
Join Date: Jun 2003
Location: New York
Posts: 10,816
|
You must nul your var
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 | |
Confirmed User
Industry Role:
Join Date: Jul 2003
Posts: 5,344
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |