2013年7月4日木曜日

Javascript for/in 文 とwith 文 の使い方

for/in 文 とwith 文 の使い方

var obj={prop1:'1',prop2:'2',prop3:'3'}

for ( var x in obj){
document.write(x + '<br>');
document.write(obj[x] + '<br>');
}

with(obj){
document.write(prop2);
}

実行の例


0 件のコメント: