JavaScript 基本類 with的使用方法

關鍵詞(keyword): with

使用with(物件){
可以略該物件名稱
}

基本用法:


  function myDetails(name,birthday){
this.name = name;
this.birthday = birthday;
}

document.write("JavaScript 基本類 - with的使用方法
");
var myDe =new myDetails("JavaScriptTest","2011/02/02");

with(myDe){
document.write(" name : " + name +"
");
document.write(" birthday : " + birthday+"
");
}

with(document){
write("with的使用方法
");
}



測試:




 















其它文章

arrow
arrow

    PG Levin Li 發表在 痞客邦 留言(0) 人氣()