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
    Nov 2009
    Posts
    40
    Thanks
    19
    Thanked 0 Times in 0 Posts

    Null check not working

    Hi All,

    This code returns "result: unknown". A successful check for null should return "result: isNull".

    Suggestions?

    Code:
    	var myValue = null;
    	var myResult = "unknown";
    	if (myValue == null) {
    		myResult == "isNull";
    	};
    	alert("value: " + myValue
    		+ "\nresult: " + myResult
    	);

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    myResult == "isNull";

    == is comparison
    = is assignment.

    So myResult = "isNull";


    In last month's article about beer and the many breweries in Belgium, 'rapist monks' should have read 'Trappist monks'. - Woking Review
    Last edited by Philip M; 03-05-2010 at 07:08 PM.

  • Users who have thanked Philip M for this post:

    WindInFace (03-05-2010)

  • #3
    New Coder
    Join Date
    Nov 2009
    Posts
    40
    Thanks
    19
    Thanked 0 Times in 0 Posts
    doh!

    Thanks Philip!


  •  

    Posting Permissions

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