Essentials of Javascript - Cultural View
Essentials of Javascript - Cultural View Essentials of Javascript - Cultural View
JavaScript syntax 33 Bitwise JavaScript supports the following binary bitwise operators: & And | Or ^ Xor > Shift right (sign-propagating); copies of the leftmost bit (sign bit) are shifted in from the left. >>> Shift right (zero fill) For positive numbers, >> and >>> yield the same result. JavaScript supports the following unary bitwise operators: ~ Not (inverts the bits) String = Assignment + Concatenation += Concatenate and assign Examples str = "ab" + "cd"; // "abcd" str += "e"; // "abcde" str2 = "2"+2 // "22", not "4" or 4. Control structures Compound statements A pair of curly brackets { } and an enclosed sequence of statements constitute a compound statement, which can be used wherever a statement can be used. If ... else if (expr) { } //statements; else if (expr2) { } else { } //statements; //statements;
JavaScript syntax 34 Conditional operator The conditional operator creates an expression that evaluates as one of two expressions depending on a condition. This is similar to the if statement that selects one of two statements to execute depending on a condition. I.e., the conditional operator is to expressions what if is to statements. var result = (condition) ? expression : alternative; is the same as: if (condition) { } else { } result = expression; result = alternative; Unlike the if statement, the conditional operator cannot omit its "else-branch". Switch statement The syntax of the JavaScript Switch statement is as follows: switch (expr) { } case SOMEVALUE: //statements; break; case ANOTHERVALUE: //statements; break; default: //statements; break; • break; is optional; however, it is usually needed, since otherwise code execution will continue to the body of the next case block. • Add a break statement to the end of the last case as a precautionary measure, in case additional cases are added later. • Strings literal values can also be used for the case values. • case default: is optional • Braces are required.
- Page 1 and 2: Essentials of Javascript Visit the
- Page 3 and 4: John Resig 122 Reverse Ajax 123 Ric
- Page 5 and 6: JavaScript 2 History Anyway I know
- Page 7 and 8: JavaScript 4 Prototype-based protot
- Page 9 and 10: JavaScript 6 LCMCalculator.prototyp
- Page 11 and 12: JavaScript 8 Example - use in web p
- Page 13 and 14: JavaScript 10 request that might ha
- Page 15 and 16: JavaScript 12 Application platform
- Page 17 and 18: JavaScript 14 See also • Client-s
- Page 19 and 20: JavaScript 16 [25] Robert Nyman, Ge
- Page 21 and 22: JavaScript syntax 18 JavaScript syn
- Page 23 and 24: JavaScript syntax 20 Primitive data
- Page 25 and 26: JavaScript syntax 22 String A Strin
- Page 27 and 28: JavaScript syntax 24 Native Objects
- Page 29 and 30: JavaScript syntax 26 } Math The Mat
- Page 31 and 32: JavaScript syntax 28 // ? - 0 or 1
- Page 33 and 34: JavaScript syntax 30 Operators The
- Page 35: JavaScript syntax 32 alert( Boolean
- Page 39 and 40: JavaScript syntax 36 With The with
- Page 41 and 42: JavaScript syntax 38 Methods A meth
- Page 43 and 44: JavaScript syntax 40 Inheritance Ja
- Page 45 and 46: JavaScript syntax 42 See also • C
- Page 47 and 48: JavaScript Style Sheets 44 } fontSi
- Page 49 and 50: JavaScript engine 46 JavaScript eng
- Page 51 and 52: Ajax (programming) 48 Ajax (program
- Page 53 and 54: Ajax (programming) 50 • Ajax-powe
- Page 55 and 56: ?: 52 ?: In computer programming, ?
- Page 57 and 58: ?: 54 Furthermore, the ternary oper
- Page 59 and 60: ?: 56 ?: in style guidelines Some c
- Page 61 and 62: Appcelerator Titanium 58 See also
- Page 63 and 64: Bookmarklet 60 Bookmarklet A bookma
- Page 65 and 66: Bookmarklet 62 References [1] Domai
- Page 67 and 68: Client-side JavaScript 64 implement
- Page 69 and 70: Client-side JavaScript 66 Reference
- Page 71 and 72: dhtmlx [1] Comparison of JavaScript
- Page 73 and 74: ility / ion Comparison of JavaScrip
- Page 75 and 76: Comparison of JavaScript frameworks
- Page 77 and 78: Comparison of JavaScript frameworks
- Page 79 and 80: Comparison of JavaScript-based sour
- Page 81 and 82: Comparison of JavaScript-based sour
- Page 83 and 84: Douglas Crockford 80 Douglas Crockf
- Page 85 and 86: DWR (Java) 82 DWR (Java) Developer(
JavaScript syntax 33<br />
Bitwise<br />
JavaScript supports the following binary bitwise operators:<br />
& And<br />
| Or<br />
^ Xor<br />
> Shift right (sign-propagating); copies <strong>of</strong> the leftmost bit (sign bit) are shifted in from the<br />
left.<br />
>>> Shift right (zero fill)<br />
For positive numbers, >> and >>> yield the same result.<br />
JavaScript supports the following unary bitwise operators:<br />
~ Not (inverts the bits)<br />
String<br />
= Assignment<br />
+ Concatenation<br />
+= Concatenate and assign<br />
Examples<br />
str = "ab" + "cd"; // "abcd"<br />
str += "e"; // "abcde"<br />
str2 = "2"+2 // "22", not "4" or 4.<br />
Control structures<br />
Compound statements<br />
A pair <strong>of</strong> curly brackets { } and an enclosed sequence <strong>of</strong> statements constitute a compound statement, which can<br />
be used wherever a statement can be used.<br />
If ... else<br />
if (expr)<br />
{<br />
}<br />
//statements;<br />
else if (expr2)<br />
{<br />
}<br />
else<br />
{<br />
}<br />
//statements;<br />
//statements;