|
| You are here: Categories » Computers and technology » AJAX and JavaScript
|
The order in which expressions are evaluated based on their operators is known as precedence. Multiplication and division occur before addition and subtraction, so any operands that are to be multiplied or divided occur before ones that are added and subtracted. Precedence can be reordered by placing expressions within parentheses. The innermost parentheses are evaluated first and work outward. So, if you want two numbers added before multiplication, place them in parentheses. The following two script excerpts show the difference results from different precedence order:
var alpha = 3 * 4 + 7 //alpha's value is 19 — 12 + 7
var beta = 3 * (4 + 7) // beta's value is 33 — 3 * 11
When all of the operators have the same precedence, the evaluations occur from left to right. The table below a precedence chart, with the lowest ranks being executed before the higher ones.
Operators Precedence
|
1
|
. [] ()
|
|
2
|
++ -- - (negation) ~ ! delete new typeof void
|
|
3
|
* / %
|
|
4
|
+ - (subtraction, addition, or concatenation)
|
|
5
|
<< >> >>> (bitwise shifts)
|
|
6
|
< > <= >=
|
|
7
|
= = != = = = != =
|
|
8
|
& (bitwise)
|
|
9
|
^ (bitwise)
|
|
10
|
| (bitwise)
|
|
11
|
&&
|
|
12
|
||
|
|
13
|
?: (ternary)
|
|
14
|
= All compound assignments (such as +=, /=, and &=)
|
|
15
|
,
|
|
|
Leave a comment or ask a question
|
|
Total comments: 0
Disclaimer
- The e-articles directory is not responsible for any and all copyright infringements by writers and authors. If you suspect the information contained by this page for any copyright infringements, please contact us to investigate the issue
|
|
|
XMLHttpRequest Overview - Originally, Microsoft designed XMLHttpRequest to allow Internet Explorer (IE) to load XML documents from JavaScript. Even though it has XML in its name, XMLHttpRequest really is a generic HTTP (more...)
Goals of AJAX - First and foremost, AJAX is about improving user experience; user experience improvements fall into two categories: making current tasks easier and making previously impossible tasks possible. (more...)
JavaScript Lives in a Web Page - All the code that you write for JavaScript goes into an HTML page. If you don't know HTML yet, you should run out and get a good book on HTML. Lynda and William Weinman's (more...)
JavaScript Literals - The raw data that make up the root of data types are called "literals." These are, in effect, literally what they represent themselves to be. Numbers, strings, and Boolean values make up the cor (more...)
JavaScript Variables - I like to think of variables as containers on a container ship. You can put all different types of content into the containers, move them to another port, empty them, and then replace the contain (more...)
JavaScript Operators - Operators can be placed into three categories-binary, unary, and ternary. Binary operators, most commonly associated with the concept of operator, take two (binary) expressions and combine them in (more...)
JavaScript Arrays - Because objects are collections of properties with each property having its own name and value, arrays are actually JavaScript objects. Each property in an array is an element, and each element (more...)
Loops in JavaScript - Loops in JavaScript are similar to loops in C++ and Java and most other languages using loop structures. In this section, you will find explanations of the different types of loops in JavaScript (more...)
Types of operators in JavaScript - Assignment Operators
The key assignment operator is the equals sign (=). The left operand is a variable, an array element, or an object property, and the righ (more...)
Conditional Structures - The "thinking" structure in JavaScript is found in the different types of conditional statements in the language. Used in concert with different types of comparative operators, conditional statem (more...)
|
|
|