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. Advertising

  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. Advertising

  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. Advertising

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. gabriele renzi
    Replies:
    2
    Views:
    202
    gabriele renzi
    Dec 31, 2005
  2. Ken Bloom
    Replies:
    3
    Views:
    206
  3. Good Night Moon
    Replies:
    9
    Views:
    280
    Rick DeNatale
    Jul 25, 2007
  4. Jacob Grover
    Replies:
    5
    Views:
    310
    Jacob Grover
    Jul 18, 2008
  5. Mark Richards
    Replies:
    3
    Views:
    310
    Tad McClellan
    Nov 18, 2007
Loading...

Share This Page