function f1()
{
function a(b)
{
return "入力文字は:「 " +b + " 」が入力されました。";
}
c = prompt("何を入力しますか?","こんにちわ!");
document.getElementById("t1").innerText=a(c);
}
if〜else,switch,case 条件分岐
function f2(){
function d(e){ return document.getElementById(e); }
var a = prompt("「い・ろ・は」の何れかを入力して下さい。","1");
if (!a)
{
d("t2").innerText="入力エラー!";
alert("何も入力されていません!")
}else{
switch(a)
{
case "い":d("t2").innerText="入力エラー!";break;
case "ろ":d("t2").innerText="2だなっ";break;
case "は":d("t2").innerText="3でしょ";break;
default:d("t2").innerText="「い・ろ・は」以外が入力されました。";
}
}
}
new,this,with オブジェクト生成省略
function f3(){
function a(b){ this.c = b * 4 }
d = new a(5);
with(document)
{
write("New Object.c = ",d.c);
}
}
new,this,with オブジェクト値取得とブーリアン
function f4(){
var a = document. fr1.in1.value;
var b = new Boolean(a);
alert(b);