Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2002
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Validation of an undeclared variable

    Hi guys. I have some client side javascript code that makes reference to a javascript variable. However, that variable may not always be there. How do I check to see if a variable has been declared? Realize that this is different than checking to see if a variable is defined. For example

    var NewVar;
    if ( NewVar == null)
    //Execute something

    This works just fine. However in my case, I'll have (in some cases)

    if ( NewVar == null)
    //Execute something

    In this case, the variable has not even been declared. The if statement generates an error that basically says that the variable hasn't been declared. Some my question becomes, how do you check to see if a variable has been declared? Thanks in advance for your help.
    Last edited by colpaarm; 08-23-2002 at 09:42 PM.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Posts
    1,404
    Thanks
    2
    Thanked 32 Times in 32 Posts

  • #3
    New Coder
    Join Date
    Aug 2002
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks big time. That did the trick.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •