Reply
Character entites as logical and comparison operators?
Old 02-01-2008, 04:41 AM Character entites as logical and comparison operators?
Experienced Talker

Posts: 47
Name: Bruce
Which should I use in my javascript code for comparisons and when testing for more than one condition?
Code:
">" or ">"?  "&&" or "&"? etc.
I thought I read somewhere that it's best to use the character entities, but maybe I was mistaken and they are only to be used when you need those special characters in html to show up on the page as that symbol.

I've just realized that the character entities don't work in javascript (when used for the purpose mentioned above) in every circumstance, which brought me to ask this question.

Have I been doing something stupid? lol

Last edited by SillyWilly : 02-01-2008 at 04:45 AM.
SillyWilly is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 02-01-2008, 08:44 AM Re: Character entites as logical and comparison operators?
chrishirst's Avatar
Super Moderator

Posts: 12,579
Location: Blackpool. UK
You use the operators NOT the entities.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 02-01-2008, 12:09 PM Re: Character entites as logical and comparison operators?
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
http://www.pageresource.com/jscript/jifelse.htm

Like Hirst said, you use the operators, not the entities.
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 02-02-2008, 12:24 AM Re: Character entites as logical and comparison operators?
Experienced Talker

Posts: 47
Name: Bruce
Thanks.

Yeah I knew all about the operators and how to use them. The link you gave me was actually the place I learned it. It's a great site. The guy teaches it well and he's pretty funny too.

I just thought I read somewhere that using the entities was better, but after I recovered from my concussion and could think better I was thinking that I must have been mistaken, especially after they didn't work in one case.
SillyWilly is offline
Reply With Quote
View Public Profile
 
Old 02-02-2008, 12:50 AM Re: Character entites as logical and comparison operators?
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Using the entities is better iff (that's if and only if, for the uninitiated) you're trying to show your code to someone else and it's not a VB-type setup whereby HTML codes such as <> are automatically converted for you (e.g. on a WordPress blog).

Then you'd have to do something like &lt; to show less than and &gt; to show greater than.

Honest mistake though. 'Sall good.
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Reply     « Reply to Character entites as logical and comparison operators?
 

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

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




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13134 seconds with 13 queries