with语句可以引用对象中已有的所有属性,但是不能给对象添加属性。
操作方法如下
function persion(){
this.name = "yib";
this.age = 25;
}
var pp = new persion();
with(pp){
alert("姓名:" + name);
alert("年龄:" + age);
}
with语句可以引用对象中已有的所有属性,但是不能给对象添加属性。
操作方法如下
function persion(){
this.name = "yib";
this.age = 25;
}
var pp = new persion();
with(pp){
alert("姓名:" + name);
alert("年龄:" + age);
}