140 lines
2.0 KiB
HTML
140 lines
2.0 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head lang="en">
|
|
<meta charset="UTF-8">
|
|
<title></title>
|
|
</head>
|
|
<body>
|
|
|
|
<script>
|
|
|
|
try {
|
|
|
|
var a = 1;
|
|
document.writeln(window.a);
|
|
document.writeln("<br>");
|
|
|
|
|
|
|
|
function persona(nome, cognome) {
|
|
this.nome = nome;
|
|
this.cognome = cognome;
|
|
this.join= function(){return this.nome + this.cognome};
|
|
}
|
|
|
|
|
|
mario = new persona("mario","marra");
|
|
mario.eta = 5;
|
|
document.writeln(mario.eta);
|
|
|
|
|
|
gino = new persona("gino","foff");
|
|
persona.prototype.eta=0;
|
|
|
|
document.writeln(gino.eta);
|
|
document.writeln(gino.join());
|
|
|
|
document.writeln("<br>");
|
|
|
|
|
|
for (i=0;i<5;i++){
|
|
document.writeln("<p>\"Io sono il num\" " + i);
|
|
}
|
|
document.writeln(i);
|
|
document.writeln("<br>");
|
|
|
|
|
|
|
|
/* bad bad
|
|
c="c";
|
|
c.a="aa";
|
|
document.writeln(c.a);
|
|
*/
|
|
|
|
c= new String("c");
|
|
c.a="aa";
|
|
document.writeln(c.a);
|
|
document.writeln("<br>");
|
|
|
|
|
|
|
|
document.writeln("3" + 4);
|
|
document.writeln(3 + "4");
|
|
document.writeln(parseInt("3") + 4);
|
|
document.writeln("3".valueOf() + 4);
|
|
document.writeln(String(3) + 4);
|
|
document.writeln("<br>");
|
|
|
|
|
|
document.writeln(mario.toString());
|
|
document.writeln(mario.valueOf());
|
|
|
|
document.writeln("<br>");
|
|
|
|
|
|
|
|
|
|
global = 1
|
|
function g (){
|
|
|
|
var global = 2; // this hide global
|
|
document.writeln(global);
|
|
function g1 (){
|
|
|
|
document.writeln(global);
|
|
}
|
|
g1();
|
|
}
|
|
g();
|
|
|
|
document.writeln(global);
|
|
|
|
|
|
|
|
req = prompt("aa");
|
|
|
|
if (req){
|
|
document.writeln(req);
|
|
} else{
|
|
document.writeln("cancel " + req);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}catch (e) {
|
|
document.writeln(e.message);
|
|
}
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
</body>
|
|
</html> |