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
    mc1
    mc1 is offline
    New to the CF scene
    Join Date
    Aug 2002
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Another newbie Q: how to check for undef

    Hi,
    I am new to javascript, having only just learned basic Perl and utilising the defined keyword, is there anything that I can utilise to check if an object is undefined or defined as in Perl?

    Thanks
    mc1

    UPDATE_UPDATE_UPDATE_UPDATE_UPDATE_UPDATE

    Thank you for the quick reply, it was just what I needed,
    went for the ...

    // code_start

    if (typeof(error2) != "undefined") {
    do something
    }
    // code_end

    instead of the myriad of other solutions instead, thanks again

    mc1
    Last edited by mc1; 08-26-2002 at 06:01 PM.

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    626
    Thanks
    0
    Thanked 0 Times in 0 Posts

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Posts
    338
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    if(typeof myVariable != "undefined") { //variable exists
    //statements...
    }
    Hope that helps!

    Happy coding!


  •  

    Posting Permissions

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