首页 > 代码库 > javascript—with用法

javascript—with用法

function Lakers() {  

       this.name = "kobe bryant";  

       this.age = "28";  

       this.gender = "boy";  

}  

var people=new Lakers();  

with(people)  

{  

       var str = "姓名: " + name + "<br>";  

       str += "年龄:" + age + "<br>";  

       str += "性别:" + gender;  

       document.write(str);  


javascript—with用法