What does this operator stand for or mean?

Discussion in 'Javascript' started by DoomedLung, Mar 25, 2006.

  1. DoomedLung

    DoomedLung Guest

    What does this operator ">-" stand for or mean, as in...


    this.ver = navigator.appVersion;

    this.agent = navigator.userAgent;

    this.dom = document.getElementById ? 1 : 0;

    this.opera5 = this.agent.indexOf("Opera 5") >- 1;

    I'm sort of a nOOb any help would much appreciated :)
    DoomedLung, Mar 25, 2006
    #1
    1. Advertising

  2. On 25/03/2006 23:15, DoomedLung wrote:

    > What does this operator ">-" stand for or mean, as in...


    [snip]

    > this.dom = document.getElementById ? 1 : 0;


    If this code must be used at all,

    this.dom = !!document.getElementById;

    would be better. See below, though.

    > this.opera5 = this.agent.indexOf("Opera 5") >- 1;


    It is, in fact, two separate operators. The greater-than relational
    operator, and the unary negation operator. The code would act the same
    (and be more readable) if it were written:

    this.opera5 = this.agent.indexOf('Opera 5') > -1;

    > I'm sort of a nOOb any help would much appreciated :)


    Then some very useful advice would be to avoid this code altogether.
    Browser detection is flawed and unreliable. Use feature detection instead.

    <http://www.jibbering.com/faq/faq_notes/not_browser_detect.html>

    Mike

    --
    Michael Winter
    Prefix subject with [News] before replying by e-mail.
    Michael Winter, Mar 25, 2006
    #2
    1. Advertising

  3. DoomedLung

    DoomedLung Guest

    Cheers for the advice and the link it makes sense now! Thanks :)
    DoomedLung, Mar 25, 2006
    #3
  4. JRS: In article <>
    , dated Sat, 25 Mar 2006 15:15:39 remote, seen in
    news:comp.lang.javascript, DoomedLung <>
    posted :
    >What does this operator ">-" stand for or mean, as in...
    >
    >
    >this.ver = navigator.appVersion;
    >
    >this.agent = navigator.userAgent;
    >
    >this.dom = document.getElementById ? 1 : 0;
    >
    >this.opera5 = this.agent.indexOf("Opera 5") >- 1;
    >
    >I'm sort of a nOOb any help would much appreciated :)


    It means that the author is a careless typist, who meant (one supposes)
    ... > -1 ;

    The previous line means that the author does not understand Booleans.

    The whole suggests that the application is unusual or the author is
    ignorant; or both.

    The first line ...


    Read the newsgroup FAQ.

    --
    © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
    <URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
    <URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
    <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
    Dr John Stockton, Mar 26, 2006
    #4
  5. DoomedLung

    DoomedLung Guest

    Cheers again! :)
    DoomedLung, Mar 28, 2006
    #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. Edward Yang

    What does ~ stand for in ImageUrl?

    Edward Yang, Jul 22, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    351
    Cowboy \(Gregory A. Beamer\) [MVP]
    Jul 22, 2004
  2. Replies:
    8
    Views:
    6,548
    David Dorward
    Nov 22, 2005
  3. C Barrington-Leigh
    Replies:
    1
    Views:
    1,178
    Tim Leslie
    Sep 10, 2010
  4. Suresh Govindachar
    Replies:
    3
    Views:
    91
    Brian McCauley
    Jul 27, 2004
  5. Plotinus
    Replies:
    2
    Views:
    285
    Tad McClellan
    Dec 17, 2004
Loading...

Share This Page