Results 1 to 4 of 4

Thread: javascript switch question?

  1. #1
    Join Date
    Mar 2005
    Beans
    305

    javascript switch question?

    HI all.

    Can some kind heart explain this line of javascript code to me please.
    Code:
    FOO = (foo==1) ? 1 : 0;
    Am I right in thinking FOO will = 1 if foo = 0 and FOO will = 0 if foo = 1??

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Beans
    2,185
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: javascript switch question?

    Quote Originally Posted by RawMustard View Post
    Am I right in thinking FOO will = 1 if foo = 0 and FOO will = 0 if foo = 1??
    No, the other way around. This will make FOO = 1 if foo = 1, and FOO = 0 if foo = 0. This is the same as:

    if (foo == 1)
    FOO = 1
    else
    FOO = 0

  3. #3
    Join Date
    Mar 2005
    Beans
    305

    Re: javascript switch question?

    Ah ha!

    Thankyou kindly

  4. #4
    Join Date
    Jan 2006
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: javascript switch question?

    and people say perl is unreadable

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
  •