[Javascript] Exemplu break + label

outerloop:
  for(var i = 0; i < 10; i++) {
    innerloop:
      for(var j = 0; j < 10; j++) {
          if (j > 3) break;             // Quit the innermost loop
          if (i == 2) break innerloop;  // Do the same thing
          if (i == 4) break outerloop;  // Quit the outer loop
          document.write("i = " + i + " j = " + j + "
");
      }
  }
  document.write("FINAL i = " + i + " j = " + j + "
"); 
 
Rezultatul fiind:
i = 0 j = 0
i = 0 j = 1
i = 0 j = 2
i = 0 j = 3
i = 1 j = 0
i = 1 j = 1
i = 1 j = 2
i = 1 j = 3
i = 3 j = 0
i = 3 j = 1
i = 3 j = 2
i = 3 j = 3
FINAL i = 4 j = 0 

[Learn JavaScript] Operatorul + este special

The + operator is a special one -- it gives priority to string operands over numeric operands. If either operand to + is a string (or an object), the other operand is converted to a string (or both operands are converted to strings) and concatenated, rather than added.

On the other hand, the comparison operators (<, >, <=, >=) perform string comparison only if both operands are strings. If only one operand is a string, JavaScript attempts to convert it to a number.

1 + 2        // Addition. Result is 3.
"1" + "2"    // Concatenation. Result is "12".
"1" + 2      // String Concatenation; 2 is converted to "2". Result is "12".
11 < 3       // Numeric comparison. Result is false.
"11" < "3"   // String comparison. Result is true.
"11" < 3     // Numeric comparison; "11" converted to 11. Result is false.
"one" < 3    // Numeric comparison; "one" converted to NaN. Result is false.
             // In JavaScript 1.1, this causes an error instead of NaN.

It is important to note that when the + operator is used with strings and numbers, it may not be associative. That is, the result may depend on the order in which operations are performed. This can be seen with examples like these:

s = 1 + 2 + " blind mice";   // Yields "3 blind mice"
t = "blind mice: " + 1 + 2;  // Yields "blind mice: 12"
 
The reason for this surprising difference in behavior is that the + operator works from left to right.

http://docstore.mik.ua/orelly/webprog/jscript/ch05_06.htm

Operatori in JavaScript

P A Operator Operand type(s) Operation performed
15 L . object, identifier Property access
  L [] array, integer Array index
  L ( ) function, arguments Function call
  R new constructor call Create new object
14 R ++ lvalue Pre- or post-increment (unary)
  R -- lvalue Pre- or post-decrement (unary)
  R - number Unary minus (negation)
  R + number Unary plus (no-op)
  R ~ integer Bitwise complement (unary)
  R ! boolean Logical complement (unary)
  R delete lvalue Undefine a property (unary)
  R typeof any Return data type (unary)
  R void any Return undefined value (unary)
13 L *, /, % numbers Multiplication, division, remainder
12 L +, - numbers Addition, subtraction
  L + strings String concatenation
11 L << integers Left shift
  L >> integers Right shift with sign-extension
  L >>> integers Right shift with zero extension
10 L <, <= numbers or strings Less than, less than or equal
  L >, >= numbers or strings Greater than, greater than or equal
  L instanceof object, constructor Check object type
  L in string, object Check whether property exists
9 L == any Test for equality
  L != any Test for inequality
  L === any Test for identity
  L !== any Test for non-identity
8 L & integers Bitwise AND
7 L ^ integers Bitwise XOR
6 L | integers Bitwise OR
5 L && booleans Logical AND
4 L || booleans Logical OR
3 R ?: boolean, any, any Conditional operator (3 operands)
2 R = lvalue, any Assignment
  R *=, /=, %=, +=, -=, <<=, >>=, >>>=, &=, ^=, |= lvalue, any Assignment with operation
1 L , any Multiple evaluation

The column labeled "P" specifies the precedence of each operator. Operator precedence controls the order in which operations are performed. Operators with higher numbers in the "P" column are performed before those with lower numbers.
Consider the following expression:
w = x + y*z; 
The multiplication operator * has a higher precedence than the addition operator +, so the multiplication is performed before the addition. Furthermore, the assignment operator = has the lowest precedence, so the assignment is performed after all the operations on the righthand side are completed.

Obs.

http://docstore.mik.ua/orelly/webprog/jscript/ch05_02.htm

Iphone CSS

Dimensiunile ecranului 320px cu 480px.

<meta name="viewport" content="width=320">

-> pentru a seta latimea ecranului (si implicit zoomul).
 
 
Putin javascript: 
 
window.scrollTo(0, 1) -> pentru a ascunde bara iphone-ului 
onorientationchange -> eveniment: la schimbarea orientarii mobilului ( portret <->orizontal ) 

http://css-tricks.com/video-screencasts/38-basics-tips-on-designing-for-the-iphone/