syntax question

Discussion in 'Javascript' started by ctx2002@gmail.com, Jul 4, 2007.

  1. Guest

    i was looking at prototype framework source code ,

    Browser: {
    IE: !!(window.attachEvent && !window.opera),
    Opera: !!window.opera,
    WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
    Gecko: navigator.userAgent.indexOf('Gecko') > -1 &&
    navigator.userAgent.indexOf('KHTML') == -1
    },

    my question is what is that !! mean?

    regards.
     
    , Jul 4, 2007
    #1
    1. Advertisements

  2. rf Guest

    <> wrote in message
    news:...
    >i was looking at prototype framework source code ,
    >
    > Browser: {
    > IE: !!(window.attachEvent && !window.opera),
    > Opera: !!window.opera,
    > WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
    > Gecko: navigator.userAgent.indexOf('Gecko') > -1 &&
    > navigator.userAgent.indexOf('KHTML') == -1
    > },
    >
    > my question is what is that !! mean?


    A ! (not) inverts the (converted to boolean) value of what follows.

    So !! converts anything to a boolean. ! (convert to boolean and invert) and
    ! again (invert it again).

    Sloppy at the very least.

    Doesn't matter anyway. What you quote above is browser sniffing which you
    should not do. Do *NOT* use prototype, or any other "framework" out there as
    a place to learn javascript.
    --
    Richard.
     
    rf, Jul 4, 2007
    #2
    1. Advertisements

  3. Guest

    so why is framework a bad choice for learning javascript.

    regards.
     
    , Jul 5, 2007
    #3
  4. On Wed, 04 Jul 2007 11:39:04 GMT, "rf" <> wrote:

    >
    ><> wrote in message
    >news:...
    >>i was looking at prototype framework source code ,
    >>
    >> Browser: {
    >> IE: !!(window.attachEvent && !window.opera),
    >> Opera: !!window.opera,
    >> WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
    >> Gecko: navigator.userAgent.indexOf('Gecko') > -1 &&
    >> navigator.userAgent.indexOf('KHTML') == -1
    >> },
    >>
    >> my question is what is that !! mean?

    >
    >A ! (not) inverts the (converted to boolean) value of what follows.
    >
    >So !! converts anything to a boolean. ! (convert to boolean and invert) and
    >! again (invert it again).
    >
    >Sloppy at the very least.
    >
    >Doesn't matter anyway. What you quote above is browser sniffing which you
    >should not do. Do *NOT* use prototype, or any other "framework" out there as
    >a place to learn javascript.


    I consider !! to be idiomatic rather than sloppy.

    ---Bruce Wisentaner
     
    Bruce Wisentaner, Jul 5, 2007
    #4
  5. wrote:
    > so why is framework a bad choice for learning javascript.


    A) A well-written framework is much too complex for a beginner. Would
    you try to learn C by studying the source code for device drivers?

    B) Pretty much everyone seems to agree that prototype.js (I'm not
    acquainted with it myself) is full of bad, bad, bad practices.
    --
    John W. Kennedy
    "When a man contemplates forcing his own convictions down another man's
    throat, he is contemplating both an unchristian act and an act of
    treason to the United States."
    -- Joy Davidman, "Smoke on the Mountain"
     
    John W. Kennedy, Jul 8, 2007
    #5
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michael Riepe

    strange VHDL syntax question

    Michael Riepe, Oct 6, 2004, in forum: VHDL
    Replies:
    1
    Views:
    774
    Mike Treseler
    Oct 11, 2004
  2. lomtik
    Replies:
    10
    Views:
    4,429
    lomtik
    Dec 24, 2004
  3. sean
    Replies:
    1
    Views:
    764
    Cowboy \(Gregory A. Beamer\)
    Oct 20, 2003
  4. gabriele renzi
    Replies:
    2
    Views:
    372
    gabriele renzi
    Dec 31, 2005
  5. Ken Bloom
    Replies:
    3
    Views:
    464
  6. Good Night Moon
    Replies:
    9
    Views:
    536
    Rick DeNatale
    Jul 25, 2007
  7. Jacob Grover
    Replies:
    5
    Views:
    523
    Jacob Grover
    Jul 18, 2008
  8. Mark Richards
    Replies:
    3
    Views:
    495
    Tad McClellan
    Nov 18, 2007
Loading...