How can I use this:
if (!zxmes && self.name != "menu")
and add if (zmes == 1)
if (!zxmes && self.name != "menu" || zmes == 1)
and make it work. 9 1745
"find clausen" <no@no987.nowro te in message
news:ce******** *************** *********@4ax.c om...
How can I use this:
if (!zxmes && self.name != "menu")
and add if (zmes == 1)
if (!zxmes && self.name != "menu" || zmes == 1)
and make it work.
There is nothing wrong with that as is. JavaScript is smart enough to know that the first
two terms are tied together via the && so that it becomes:
if ((!zxmes && self.name) || zmes == 1)
If you think this is somehow the culprit you could always just write it (as I have done)
out with additional parenthesis.
To show that your example works though:
var zxmes = null; // satisfies !zxmes
self.name = 'not menu'; // satisfies self.menu != 'menu'
var zmes = 1; // satisifes zmes == 1
With those variables your if statement is always true.
Change zmes to something other than 1, your if is still true.
Change either zxmes to a valid value or self.name to 'menu' and zmes to something other
than 1 and it fails.
-Lost
On Jan 28, 8:58 pm, find clausen <n...@no987.now rote:
How can I use this:
if (!zxmes && self.name != "menu")
and add if (zmes == 1)
if (!zxmes && self.name != "menu" || zmes == 1)
and make it work.
How do you do 5+3*2 so to add first 5 and 3 and then multiply 2? ;-)
Right, by using parenthesis: (5+3)*2
In JavaScript involved operators precedence is:
....
2) !
....
7) ==
....
11) &&
12) ||
....
That makes pretty clear I believe where are parenthesis going.
JavaScript is smart enough to know that the first
two terms are tied together via the &&
Expression evaluation in programming languages is not an AI or
guessing process ;-) Everything is strictly defined in what is called
"Operator Precedence Table". The only way to break this precedence is
by using parenthesis. && stays by precedence way below ! and != so
grouping parenthesis are needed.
JavaScript operator precedence table consists of 15 positions; I'm
jumping on a chance to post it in full - because however important
this table is many people are not aware of it.
15 positions, from the highest priority to the lowest one:
1) . [] ()
Property accessor, array indexing, function calls, and expression
grouping
2) ++ -- - ~ ! delete new typeof void
Unary operators, return data type, object creation, undefined values
3) * / %
Multiplication, division, modulo division
4) + - +
Addition, subtraction, string concatenation
5) << >>>
Bit shifting
6) < <= = instanceof
Less than, less than or equal, greater than, greater than or equal,
instanceof
7) == != === !==
Equality, inequality, strict equality, and strict inequality
8) &
Bitwise AND
9) ^
Bitwise XOR
10) |
Bitwise OR
11) &&
Logical AND
12) ||
Logical OR
13) ?:
Ternary conditional
14) =
Assignment
15) ,
Comma (multiple evaluation)
"VK" <sc**********@y ahoo.comwrote in message
news:11******** **************@ m58g2000cwm.goo glegroups.com.. .
On Jan 28, 8:58 pm, find clausen <n...@no987.now rote:
>How can I use this:
if (!zxmes && self.name != "menu")
and add if (zmes == 1)
if (!zxmes && self.name != "menu" || zmes == 1)
and make it work.
How do you do 5+3*2 so to add first 5 and 3 and then multiply 2? ;-)
Right, by using parenthesis: (5+3)*2
In JavaScript involved operators precedence is:
...
2) !
...
7) ==
...
11) &&
12) ||
...
That makes pretty clear I believe where are parenthesis going.
Where did you get your numbers from? From: http://www.codehouse.com/javascript/precedence/
I get:
....
4. !
....
9. ==
....
13. &&
14. ||
....
Not like it really matters I guess... I am just curious.
-Lost
In JavaScript involved operators precedence is:
>
...
2) !
...
7) ==
...
11) &&
12) ||
...
>Where did you get your numbers from?
Originally (several years ago) from Netscape JavaScript Reference,
then checked against JScript Operator Precedence from MSDN
From: http://www.codehouse.com/javascript/precedence/
I get:
...
4. !
...
9. ==
...
13. &&
14. ||
...
I have no idea where their numbering came from. There are a lot of
most strange resources about JavaScript floating in the Web. :-\
On the first look (did not spend time for the second one :-) they
mixed hell together operator precedence (priority) and operator
associativity - the last one comes into play with equal priority, say
in 2+2-3
This is why they've got such strange order and extra precedence
positions.
>
-Lost
Where did you get your numbers from?
Originally (several years ago) from Netscape JavaScript Reference,
then checked against JScript Operator Precedence from MSDN
Netscape DevEdge is gone long ago, but I believe this was the table I
started with in 1998:
< http://devedge-temp.mozilla.org/libr...avascript/1.3/
guide/expr.html#10087 50>
It contains pretty much the same defaults as < http://www.codehouse.com/
javascript/precedence/so I guess it is based on JavaScript 1.3 table
The correct 15 position table I'm using (with associativity taken out
and only priority lleft) is pretty much the same as <http://
msdn2.microsoft .com/en-US/library/z3ks45k7.aspxor <http://
ns7.webmasters. com/caspdoc/html/jscript_operato r_precedence.ht m>
- with some terms correction (like ?: ternary operator called some
fantastic term "Condition" on MSDN)
In comp.lang.javas cript message <11************ **********@m58g 2000cwm.go
oglegroups.com> , Sun, 28 Jan 2007 10:36:30, VK <sc**********@y ahoo.com>
posted:
>How do you do 5+3*2 so to add first 5 and 3 and then multiply 2? ;-) Right, by using parenthesis: (5+3)*2
Commonly but not necessarily. In RPN, 5 3 + 2 * is 16 and
parentheses (note spelling of plural form) are not needed to control
expression evaluation. With longcalc.exe, via sig line 3,
longcalc 5 3 add 2 mul wrt
- +16
longcalc 987654321 5 bas #ge wrt wrt
- +4 +32
Gregorian Easter Sunday of Gregorian AD 987654321 will be on Month 4 day
32 (to base 5).
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon. co.uk DOS 3.3, 6.20; WinXP.
Web <URL:http://www.merlyn.demo n.co.uk/- FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demo n.co.uk/programs/00index.htm>
My DOS <URL:http://www.merlyn.demo n.co.uk/batfiles.htm- also batprogs.htm.
In article <11************ **********@p10g 2000cwp.googleg roups.com>, VK
<sc**********@y ahoo.comwrites
>JavaScript is smart enough to know that the first two terms are tied together via the &&
Expression evaluation in programming languages is not an AI or guessing process ;-) Everything is strictly defined in what is called "Operator Precedence Table".
<snip>
It's the syntax specification that 'strictly defines' the meaning of
expressions. That's things like
ConditionalExpr ession :
LogicalORExpres sion
LogicalORExpres sion ? AssignmentExpre ssion : AssignmentExpre ssion
A precedence table is a useful memory aid, but it doesn't always give
the right answer.
>13) ?:
Ternary conditional
14) =
Assignment
15) ,
Comma (multiple evaluation)
The conditional operator causes problems for precedence tables (also in
other languages). For instance, how about
a = b ? c = d : e = f;
The precedence numbers don't work here. You have to go back to the
syntax specification.
John
--
John Harris
On Jan 29, 11:32 pm, John G Harris <j...@nospam.de mon.co.ukwrote:
Comma (multiple evaluation)The conditional operator causes problems for precedence tables (also in
other languages). For instance, how about
a = b ? c = d : e = f;
Easy to check:
<script>
var a = 0;
var b = 1;
var c = 2;
var d = 3;
var e = 4;
var f = 5;
var g = a = b ? c = d : e = f;
alert(d); // 3
</script>
Ternary conditional has higher priority than assignment (13th position
against 14th), so it is evaluated first and only then assigned to g.
Actually ternary conditional implementation in javascript is the most
robust - because it was made with all oops in C/C++/Java in mind. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Collin VanDyck |
last post by:
I have a basic understanding of this, so forgive me if I am overly
simplistic in my explanation of my problem..
I am trying to get a Java/Xalan transform to pass through a numeric
character reference (i.e. ) and it seems to be converting the
character to its UNICODE representation.
Take this source XML document:
<?xml version="1.0" encoding="UTF-8"?>
|
by: DrTebi |
last post by:
Hello,
I have the following problem:
I used to "encode" my email address within links, in order to avoid (most)
email spiders. So I had a link like this:
<a
href="mailto:DrTebi@yahoo.com">DrTebi</a>
This would work like a regular mailto link in any browser, but wouldn't be
visible to spiders if they don't have a function to decode it.
|
by: Thomas Scheffler |
last post by:
Hi,
I runned in trouble using XALAN for XSL-Transformation.
The following snipplet show what I mean:
<a href="http://blah.com/?test=test&test2=test2">Test1&</a>
<a href="http://blah.com/?test=test&amp;test2=test2">Test2&amp;</a>
This results in the following HTML Code:
|
by: Luklrc |
last post by:
Hi,
I'm having to create a querysting with javascript. My problem is that
javscript turns the "&" characher into "&" when it gets used as a
querystring in the url EG:
/mypage.asp?value1=1&value2=4& ...
which of course means nothing to asp.
|
by: johkar |
last post by:
When the output method is set to xml, even though I have CDATA around
my JavaScript, the operaters of && and < are converted to XML character
entities which causes errors in my JavaScript. I know that I could
externalize my JavaScript, but that will not be practical throughout
this application. Is there any way to get around this issue? Xalan
processor. Stripped down stylesheet below along with XHTML output.
<?xml version='1.0'?>...
| |
by: Nathan Sokalski |
last post by:
I add a JavaScript event handler to some of my Webcontrols using the
Attributes.Add() method as follows:
Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);"
TextBox2.Attributes.Add("onKeyPress", jscode)
You will notice that jscode contains the JavaScript Logical And operator
(&&). However, ASP.NET renders this as && in the code that is
|
by: Jeremy |
last post by:
How can one stop a browser from converting
&
to
& ?
We have a textarea in our system wehre a user can type in some html code
and have it saved to the database. When the data is retireved and
|
by: Arne |
last post by:
A lot of Firefox users I know, says they have problems with validation
where the ampersand sign has to be written as & to be valid. I don't
have Firefox my self and don't wont to install it only because of this,
so I hope some of you gurus can enlighten me with this :)
In what circumstances can the "&" in the source code be involuntary
changed to "&" by a browser when or other software, when editing and
uploading the file to the web...
|
by: InvalidLastName |
last post by:
We have been used XslTransform. .NET 1.1, for transform XML document, Dataset with xsl to HTML. Some of these html contents contain javascript and links. For example:
// javascript
if (a > b)
.....
// xsl contents
abc.aspx?p1=v1&p2=<xsl:value-of select="$v2" />
|
by: John Nagle |
last post by:
I've been parsing existing HTML with BeautifulSoup, and occasionally
hit content which has something like "Design & Advertising", that is,
an "&" instead of an "&". Is there some way I can get BeautifulSoup
to clean those up? There are various parsing options related to "&"
handling, but none of them seem to do quite the right thing.
If I write the BeautifulSoup parse tree back out with "prettify",
the loose "&" is still in there. So...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |