SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2004
    Location
    Farmington
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Not able to check if variable is undefined

    I have the following variable which has value of '-45'. I have the single quotes around the value to be able pass to a CAML query. Looks like the issue is related to that but don't know how to get around it (other than adding single quotes to my query itself).

    var paramGetBy = "'-45'";

    I am not able to check if the variable is undefined (when I comment the above line of code). I tried all the following ways.

    if (!paramGetBy)
    if (paramGetBy == null)
    if (typeof(paramGetBy) == 'undefined')
    if (typeof(paramGetBy) === 'undefined')


    But, I am getting 'undefined' if I put the following alert when the variable is defined.
    alert(paramGetBy);

  2. #2
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <script type="text/javascript">

    //var paramGetBy = "'-45'";

    if( typeof( paramGetBy ) === 'undefined' )
    alert( 'UNDEFINED' );
    else
    alert( paramGetBy );

    </script>
    Tab-indentation is a crime against humanity.


Bookmarks

Posting Permissions

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