Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>espressioni, precedenze ed associatività</title>
- </head>
- <body>
- <script type="text/javascript">
- let br = "<br>";
- //operatori di assegnamento
- let x = 49.99;
- x += 5; //x = x+5
- x -= 5; //x = x-5;
- x*=2; // x = x*2;
- x/=2; // x = x / 2;
- document.write( x + br);
- x = 4;
- let y = 3;
- x += (6 - y) * (x - y);
- document.write( x + br); //7
- //pre e post incremento/decremento
- x = 0;
- y = ++x; //pre incremento: prima si incrementa x e poi la si usa
- document.write( y + br); //y==1, x==1
- x = 0;
- y = x--; //post decremento: prima si usa la x e poi la si incrementa
- document.write( y + br); //y==0, x==-1
- let nome="Alessandro", conta=0;
- while (conta<nome.length)
- {
- document.write( nome.charAt(conta) + br);
- conta++;
- }
- //operatore virgola
- for (let i = 0, j = 9; i <= j; i++, j--)
- {document.write(i + (j + " ") );}
- document.write(br);
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement