What does this operator stand for or mean?

D

DoomedLung

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 :)
 
M

Michael Winter

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
 
D

Dr John Stockton

JRS: In article <[email protected]>
, dated Sat, 25 Mar 2006 15:15:39 remote, seen in
news:comp.lang.javascript said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top