Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > What does this operator stand for or mean?

Reply
Thread Tools

What does this operator stand for or mean?

 
 
DoomedLung
Guest
Posts: n/a
 
      03-25-2006
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

 
Reply With Quote
 
 
 
 
Michael Winter
Guest
Posts: n/a
 
      03-25-2006
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.
 
Reply With Quote
 
 
 
 
DoomedLung
Guest
Posts: n/a
 
      03-25-2006
Cheers for the advice and the link it makes sense now! Thanks

 
Reply With Quote
 
Dr John Stockton
Guest
Posts: n/a
 
      03-26-2006
JRS: In article < .com>
, 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.
 
Reply With Quote
 
DoomedLung
Guest
Posts: n/a
 
      03-28-2006
Cheers again!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
what does thtml stand for yihucd@gmail.com HTML 8 11-22-2005 07:44 PM
What does MCNGP stand for? Jonathan Adams MCSE 72 06-13-2005 03:11 PM
stand alone executable using pp doesn't stand alone Plotinus Perl Misc 2 12-17-2004 01:09 AM
What does ~ stand for in ImageUrl? Edward Yang ASP .Net 2 07-22-2004 01:18 PM
What does rtfm stand for? E. Robert Tisdale C Programming 1 08-07-2003 05:09 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57