<script type="text/javascript"> function Dog(){ this.type="dog"; this.tail=1; this.bark="wangwang"; } var ahuang=new Dog(); //alert(ahuang.bark); with(ahuang){ alert(bark); } </script>
with用于引用某js对象的已有属性
<script type="text/javascript"> function Dog(){ this.type="dog"; this.tail=1; this.bark="wangwang"; } var ahuang=new Dog(); //alert(ahuang.bark); with(ahuang){ alert(bark); } </script>
with用于引用某js对象的已有属性