www.webdeveloper.com
Results 1 to 5 of 5

Thread: How to check the value of a variable

  1. #1
    Join Date
    Nov 2013
    Posts
    8

    How to check the value of a variable

    The problem I have is that a value of a variable is blanc but it's not "" or " " or Null. I tried to print the value:

    Code:
    document.write("h" . getrouteDest3 . "h");
    Nothing is printed. If I remove the getrouteDest3 "hh" is printed. How can I check the value of getrouteDest3 if nothing is printed?

  2. #2
    Join Date
    Dec 2011
    Location
    Centurion, South Africa
    Posts
    795
    You're using the PHP method of appending strings together (.).
    In JavaScript you must use +:

    Code:
    document.write("h" + getrouteDest3 + "h");
    JavaScript: Learn | Validate | Compact | bionoid

  3. #3
    Join Date
    Nov 2013
    Posts
    8
    Quote Originally Posted by bionoid View Post
    You're using the PHP method of appending strings together (.).
    In JavaScript you must use +:

    Code:
    document.write("h" + getrouteDest3 + "h");
    thanks, I checked the variable with typeOf and it is a "string". Is null a string or another type?

    Can it be other than "" or " "?

  4. #4
    Join Date
    Oct 2012
    Location
    Croatia
    Posts
    255
    If you use the typeof operator on null you'll get object. This means that null is a special object value which indicates "no object". Null is typically regarded as a special value of its own type that indicates no value, unknown value or missing value...

  5. #5
    Join Date
    Oct 2012
    Location
    Croatia
    Posts
    255
    Quote Originally Posted by md7dani View Post

    Can it be other than "" or " "?
    Don't understand this...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles