SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jul 2007
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy ?0:1; ?????? What this means?

    hello,

    Can someone help me, i'm idiot in javascript.

    Someone can expalain to me what the numbering in the end of line means.---> ?0:1;

    abc_element = (!document.getElementById("abc") )?0:1;


    Thanks in advance.

  2. #2
    SitePoint Zealot Shpook's Avatar
    Join Date
    May 2007
    Location
    Hollywood, FL, USA
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know a single thing about Javascript, but it looks like some kind of Boolean operator.
    Life would be so much easier if we
    could just look at the source code.
    -Dave Olson

  3. #3
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's called a ternary operator. It's just a short form of writing:
    Code:
    if (!document.getElementById("abc")) {
      abc_element = 0;
    } else {
      abc_element = 1;
    }


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
  •